List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:CoolBarComboButton.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); CoolBar bar = new CoolBar(shell, SWT.BORDER); CoolItem item = new CoolItem(bar, SWT.NONE); Button button = new Button(bar, SWT.PUSH); button.setText("Button "); 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*/ item = new CoolItem(bar, SWT.NONE); Combo combo = new Combo(bar, SWT.NONE); size = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT); item.setPreferredSize(item.computeSize(size.x, size.y)); item.setControl(combo); bar.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet114.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 114"); Tree tree = new Tree(shell, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); for (int i = 0; i < 12; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Item " + i); }//from www . ja v a 2s . c om Rectangle clientArea = shell.getClientArea(); tree.setBounds(clientArea.x, clientArea.y, 100, 100); tree.addListener(SWT.Selection, event -> { String string = event.detail == SWT.CHECK ? "Checked" : "Selected"; System.out.println(event.item + " " + string); }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:RowLayoutTest.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); RowLayout layout = new RowLayout(SWT.VERTICAL); layout.marginLeft = 12;//from w w w . j a v a2 s. c o m layout.marginTop = 0; layout.justify = true; shell.setLayout(layout); new Button(shell, SWT.PUSH).setText("one"); new Button(shell, SWT.PUSH).setText("two"); new Button(shell, SWT.PUSH).setText("three"); new Button(shell, SWT.PUSH).setText("four"); new Button(shell, SWT.PUSH).setText("five"); new Button(shell, SWT.PUSH).setText("six"); Button b = new Button(shell, SWT.PUSH); b.setText("seven"); b.setLayoutData(new RowData(100, 100)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutTest.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); RowLayout layout = new RowLayout(SWT.VERTICAL); layout.marginLeft = 20;/*from w w w. j a v a2 s. c o m*/ layout.marginTop = 20; layout.justify = true; shell.setLayout(layout); new Button(shell, SWT.PUSH).setText("one"); new Button(shell, SWT.PUSH).setText("two"); new Button(shell, SWT.PUSH).setText("three"); new Button(shell, SWT.PUSH).setText("four"); new Button(shell, SWT.PUSH).setText("five"); new Button(shell, SWT.PUSH).setText("six"); Button b = new Button(shell, SWT.PUSH); b.setText("seven"); b.setLayoutData(new RowData(100, 100)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet345.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(); shell.setText("Snippet 345"); shell.setLayout(new FillLayout(SWT.VERTICAL)); String string = "The quick brown fox jumps over the lazy dog"; Button button;/* w w w . j ava2 s . com*/ button = new Button(shell, SWT.PUSH | SWT.WRAP); button.setText(string); button = new Button(shell, SWT.RADIO | SWT.WRAP); button.setText(string); button = new Button(shell, SWT.TOGGLE | SWT.WRAP); button.setText(string); button = new Button(shell, SWT.CHECK | SWT.WRAP); button.setText(string); shell.setSize(shell.computeSize(200, SWT.DEFAULT)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet49.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 49"); final ToolBar toolBar = new ToolBar(shell, SWT.WRAP); for (int i = 0; i < 12; i++) { ToolItem item = new ToolItem(toolBar, SWT.PUSH); item.setText("Item " + i); }/* w w w . ja v a2s . co m*/ shell.addListener(SWT.Resize, e -> { Rectangle rect = shell.getClientArea(); Point size = toolBar.computeSize(rect.width, SWT.DEFAULT); toolBar.setSize(size); }); Rectangle clientArea = shell.getClientArea(); toolBar.setLocation(clientArea.x, clientArea.y); toolBar.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:CLabelGradientBackgroundThreeColors.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("CLabel Gradient"); shell.setLayout(new GridLayout(1, false)); CLabel one = new CLabel(shell, SWT.LEFT); one.setText("Second Gradient Example"); one.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Set the background gradient one.setBackground(new Color[] { shell.getDisplay().getSystemColor(SWT.COLOR_WHITE), shell.getDisplay().getSystemColor(SWT.COLOR_GRAY), shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY), shell.getDisplay().getSystemColor(SWT.COLOR_BLACK) }, new int[] { 33, 67, 100 }); shell.open();//from w w w .j a v a 2 s. com while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:LayoutSpaceProperties.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); FillLayout fillLayout = new FillLayout(SWT.HORIZONTAL); fillLayout.marginWidth = 5;/*www . jav a2 s . c o m*/ fillLayout.marginHeight = 5; // Number of pixels between the edge of a cell and edges of its neighboring cells fillLayout.spacing = 10; shell.setLayout(fillLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button number 2"); Button button3 = new Button(shell, SWT.PUSH); button3.setText("3"); shell.setSize(450, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:PNGFileWriteImage.java
public static void main(String[] args) { Display display = new Display(); Font font = new Font(display, "Comic Sans MS", 24, SWT.BOLD); Image image = new Image(display, 87, 48); GC gc = new GC(image); gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); gc.fillRectangle(image.getBounds()); gc.setFont(font);//from w w w. j a v a 2 s . co m gc.setForeground(display.getSystemColor(SWT.COLOR_RED)); gc.drawString("S", 3, 0); gc.setForeground(display.getSystemColor(SWT.COLOR_GREEN)); gc.drawString("W", 25, 0); gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); gc.drawString("T", 62, 0); gc.dispose(); ImageLoader loader = new ImageLoader(); loader.data = new ImageData[] { image.getImageData() }; loader.save("swt.png", SWT.IMAGE_PNG); image.dispose(); font.dispose(); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet113.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 113"); Table table = new Table(shell, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); }/*from w w w .j a va 2s. com*/ Rectangle clientArea = shell.getClientArea(); table.setBounds(clientArea.x, clientArea.y, 100, 100); table.addListener(SWT.Selection, event -> { String string = event.detail == SWT.CHECK ? "Checked" : "Selected"; System.out.println(event.item + " " + string); }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }