Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Scrolls doesn't scroll in SWT

Reply
Thread Tools

Scrolls doesn't scroll in SWT

 
 
barbara.morey barbara.morey is offline
Junior Member
Join Date: Sep 2008
Posts: 2
 
      09-10-2008
Hello, I'm doing a program and I'm finishing its interface. In one window I have to show some photos and I need to scroll it. The problem is that I've put the scroll and it goes up & down but the window is always in the same position. I don't know how to solve it, please I need help.

I put the code below:

Menu_bar.java:

package interficie;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;

public class Menu_bar {

Shell shell;
Display display;

Menu_bar() {

display = new Display();
shell = new Shell(display);
shell.setText("The Vertex Coloring Algorithm");
shell.setSize(500, 600);

Menu menuBar = new Menu(shell, SWT.BAR);
MenuItem examples = new MenuItem(menuBar, SWT.CASCADE);
examples.setText("Ejemplos");
Menu FileExamples = new Menu(shell, SWT.DROP_DOWN);
examples.setMenu(FileExamples);
MenuItem selectExamples= new MenuItem(FileExamples, SWT.CASCADE);
selectExamples.setText("Elegir ejemplo");

selectExamples.addSelectionListener(new MenuItemListener());

shell.setMenuBar(menuBar);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}

class MenuItemListener extends SelectionAdapter {
public void widgetSelected(SelectionEvent event) {
if (((MenuItem) event.widget).getText().equals("Elegir ejemplo")) {
Choose2 choose2= new Choose2(shell);
}
}
}

public static void main(String[] argv) {
new Menu_bar();
}
}

Choose2.java (Here's the problem with the scroll bar):

package interficie;

import java.io.InputStream;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class Choose2 extends Dialog {
public Choose2(Shell parent) {
super(parent);
initialize();
}

public void initialize() {
Shell parent = getParent();
final Shell dialog = new Shell(parent, SWT.DIALOG_TRIM
| SWT.APPLICATION_MODAL |SWT.BORDER | SWT.V_SCROLL);
dialog.setSize(500, 800);
dialog.setText("Elegir ejemplo");

// Declaramos el número de buttons que necesitaremos
Button[] radios = new Button[20];

GridLayout gridLayout = new GridLayout(3,true);
dialog.setLayout(gridLayout);

GridData gridData = new GridData(GridData.BEGINNING);
gridData.grabExcessHorizontalSpace = true;

Display display = parent.getDisplay();


// Insertamos imagen1
InputStream is1 = ClassLoader.getSystemClassLoader().getResourceAsSt ream("images/bondy-murty.bmp");
Image image1 = new Image(null, is1);
Label l1 = new Label (dialog, SWT.BEGINNING);
l1.setImage(image1);

// Insertamos imagen2
InputStream is2 = ClassLoader.getSystemClassLoader().getResourceAsSt ream("images/bondy-murty2.bmp");
Image image2 = new Image(null, is2);
Label l2 = new Label (dialog, SWT.BEGINNING);
l2.setImage(image2);

// Insertamos imagen3
InputStream is3 = ClassLoader.getSystemClassLoader().getResourceAsSt ream("images/bondy-murty3.bmp");
Image image3 = new Image(null, is3);
Label l3 = new Label (dialog, SWT.BEGINNING);
l3.setImage(image3);

// Insertamos radiobuttons
radios[0] = new Button(dialog, SWT.RADIO);
radios[0].setSelection(true);
radios[0].setText("bondy-murty");
radios[0].setBounds(10, 5, 75, 30);

radios[1] = new Button(dialog, SWT.RADIO);
radios[1].setText("bondy-murty2");
radios[1].setBounds(10, 30, 75, 30);

radios[2] = new Button(dialog, SWT.RADIO);
radios[2].setText("bondy-murty3");
radios[2].setBounds(10, 55, 75, 30);

// Ejecutamos la interfaz
dialog.open();
while (!dialog.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}



Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SWT Table's scroll event kamiseq Java 0 01-20-2008 04:51 PM
Where can I download SWT? (SWT homepage) Ramon F Herrera Java 11 12-06-2007 03:18 AM
Scroll mouse scrolls left and right Invalid Computer Support 3 05-19-2006 06:49 PM
scrolls scrolls scrolls scrolls scrolls ............... =?Utf-8?B?ZG90bmV0a3VtYXI=?= ASP .Net 0 08-04-2005 08:55 AM
Table that scrolls if too long BUT first row is static? Noozer HTML 1 06-16-2005 07:11 AM



Advertisments