List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:MainClass.java
public static void main(String[] a) { Display d = new Display(); final Shell s = new Shell(d); s.setSize(250, 200);/*w ww. ja v a2 s . c om*/ s.setText("A MouseListener Example"); s.open(); s.addMouseListener(new MouseListener() { public void mouseDown(MouseEvent e) { System.out.println("Mouse Button Down at:" + e.x + " " + e.y); } public void mouseUp(MouseEvent e) { System.out.println("Mouse Button up at:" + e.x + " " + e.y); System.out.println(e.button); } public void mouseDoubleClick(MouseEvent e) { System.out.println("Mouse Double Clicked at:" + e.x + " " + e.y); } }); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:DateTimeDialogCreate.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); DateTime calendar = new DateTime(shell, SWT.CALENDAR); calendar.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { System.out.println("calendar date changed"); }//from w w w . j a v a 2 s. co m }); DateTime time = new DateTime(shell, SWT.TIME); time.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { System.out.println("time changed"); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet20.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 20"); CoolBar bar = new CoolBar(shell, SWT.BORDER); for (int i = 0; i < 2; i++) { CoolItem item = new CoolItem(bar, SWT.NONE); Button button = new Button(bar, SWT.PUSH); button.setText("Button " + i); Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT); item.setPreferredSize(item.computeSize(size.x, size.y)); item.setControl(button);//from w ww .j a v a 2 s . c o m } Rectangle clientArea = shell.getClientArea(); bar.setLocation(clientArea.x, clientArea.y); bar.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:SWTButtonExampleDemo.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setSize(300, 200);/*from ww w. j av a 2 s .c o m*/ shell.setText("Button Example"); shell.setLayout(new RowLayout()); final Button button = new Button(shell, SWT.PUSH); button.setText("Click Me"); final Text text = new Text(shell, SWT.SHADOW_IN); button.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { text.setText("No worries!"); } public void widgetDefaultSelected(SelectionEvent event) { text.setText("No worries!"); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ImageCopyCreation.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Canvas Example"); shell.setLayout(new FillLayout()); Canvas canvas = new Canvas(shell, SWT.NONE); canvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Image image = new Image(display, "yourFile.gif"); Image copy = new Image(display, image, SWT.IMAGE_COPY); e.gc.drawImage(copy, 10, 10); e.gc.drawImage(copy, 10, 50); image.dispose();/* w w w.jav a2 s .c om*/ copy.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION); for (int i = 0; i < 5; i++) { TableColumn column = new TableColumn(table, SWT.NONE); }//from w w w .j a va 2 s.com for (int i = 0; i < 10; i++) { TableItem item = new TableItem(table, SWT.NONE); for (int j = 0; j < 5; j++) { item.setText(j, "Row " + i + ", Column " + j); } } for (int i = 0, n = table.getColumnCount(); i < n; i++) { table.getColumn(i).pack(); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ControlTabTransversing.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Text text1 = new Text(shell, SWT.SINGLE | SWT.BORDER); text1.setText("Can't Traverse"); text1.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: { e.doit = false;//w w w .j av a 2 s . c o m } } } }); Text text2 = new Text(shell, SWT.SINGLE | SWT.BORDER); text2.setText("Can Traverse"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:RowLayoutMargin.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.marginLeft = 20;//from w w w .j a v a 2 s . c o m rowLayout.marginRight = 20; rowLayout.marginTop = 20; rowLayout.marginBottom = 20; shell.setLayout(rowLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:DialogEmptyDisplay.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP); final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLayout(new RowLayout()); dialog.pack();//from w ww . java 2 s. c o m dialog.open(); // Move the dialog to the center of the top level shell. Rectangle shellBounds = shell.getBounds(); Point dialogSize = dialog.getSize(); dialog.setLocation(shellBounds.x + (shellBounds.width - dialogSize.x) / 2, shellBounds.y + (shellBounds.height - dialogSize.y) / 2); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:StackLayoutTest.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); StackLayout layout = new StackLayout(); shell.setLayout(layout);//from w ww . j av a 2s . c o m StackLayoutSelectionAdapter adapter = new StackLayoutSelectionAdapter(shell, layout); Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.addSelectionListener(adapter); Button two = new Button(shell, SWT.PUSH); two.setText("two"); two.addSelectionListener(adapter); Button three = new Button(shell, SWT.PUSH); three.setText("three"); three.addSelectionListener(adapter); layout.topControl = one; shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }