List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:SashFormSashWidth.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SashForm Test"); // Fill the parent window with the buttons and sash shell.setLayout(new FillLayout()); // Create the SashForm and the buttons SashForm sashForm = new SashForm(shell, SWT.VERTICAL); new Button(sashForm, SWT.PUSH).setText("Left"); new Button(sashForm, SWT.PUSH).setText("Right"); sashForm.SASH_WIDTH = 20;// www . j a va 2 s . c o m shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ButtonSelection.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); for (int i = 0; i < 20; i++) { Button button = new Button(shell, SWT.TOGGLE); button.setText("B" + i); }/*from ww w . j ava 2s . c o m*/ Control[] children = shell.getChildren(); for (int i = 0; i < children.length; i++) { Control child = children[i]; ((Button) child).setSelection(true); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:StyledTextClipboard.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); StyledText text1 = new StyledText(shell, SWT.V_SCROLL | SWT.WRAP | SWT.BORDER); StyledText text2 = new StyledText(shell, SWT.V_SCROLL | SWT.WRAP | SWT.BORDER); text1.setText("1234567"); text1.setSelectionRange(2, 4);/*ww w.j av a 2s .co m*/ text1.cut(); text2.paste(); text1.setBounds(10, 10, 100, 100); text2.setBounds(10, 300, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FillRectangle.java
public static void main(String[] args) { Display display = new Display(); 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) { e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.fillRectangle(30, 40, 400, 200); }// ww w . j a v a2 s .c o m }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:TabItemAddPushButton.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER | SWT.BOTTOM); for (int i = 0; i < 6; i++) { TabItem item = new TabItem(tabFolder, SWT.NONE); item.setText("TabItem " + i); Button button = new Button(tabFolder, SWT.PUSH); button.setText("Page " + i); item.setControl(button);//from w w w. ja va2s. c o m } tabFolder.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet35.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 35"); Table table = new Table(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, 0); item.setText("Item " + i); }//from w w w. j av a 2 s. c o m Rectangle clientArea = shell.getClientArea(); table.setBounds(clientArea.x, clientArea.y, 100, 100); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet99.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 99"); shell.addListener(SWT.Close, event -> { int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO; MessageBox messageBox = new MessageBox(shell, style); messageBox.setText("Information"); messageBox.setMessage("Close the shell?"); event.doit = messageBox.open() == SWT.YES; });//from w w w . java2 s . c o m shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { final Display d = new Display(); final Shell shell = new Shell(d); shell.setSize(250, 200);//from w w w. j a v a 2 s . c o m shell.setLayout(new FillLayout()); // Create a canvas Canvas canvas = new Canvas(shell, SWT.NONE); canvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_BLACK)); e.gc.drawOval(100, 20, 100, 50); } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:DrawArcSWT.java
public static void main(String[] args) { Display display = new Display(); 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) { e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_BLACK)); e.gc.fillArc(200, 100, 500, 400, 30, 40); }/*from w ww. jav a2 s.c o m*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FileSaveDialogFilterNameFilterExtensions.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); FileDialog dialog = new FileDialog(shell, SWT.SAVE); dialog.setFilterNames(new String[] { "Batch Files", "All Files (*.*)" }); dialog.setFilterExtensions(new String[] { "*.bat", "*.*" }); // Windows // wild cards dialog.setFilterPath("c:\\"); // Windows path dialog.setFileName("yourFile.bat"); System.out.println("Save to: " + dialog.open()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep();// w w w . j ava2 s. com } display.dispose(); }