List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:ImageLoadingFromFile.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"); e.gc.drawImage(image, 10, 10); image.dispose();/*w w w . j av a 2 s . c o m*/ } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet233.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Parent Shell"); shell.addMouseListener(mouseDownAdapter(e -> { Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); Point pt = display.getCursorLocation(); dialog.setLocation(pt.x, pt.y);/*w w w. jav a2 s .com*/ dialog.setText("Dialog Shell"); dialog.setSize(100, 100); dialog.open(); })); shell.setSize(400, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { final String[] ITEMS = { "A", "B", "C", "D", "E" }; Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); // Create a drop-down combo Combo combo = new Combo(shell, SWT.DROP_DOWN); combo.setItems(ITEMS);/*from w w w . j a va 2 s . c o m*/ // Create a read only combo Combo readOnly = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY); readOnly.setItems(ITEMS); // Create a "simple" combo Combo simple = new Combo(shell, SWT.SIMPLE); simple.setItems(ITEMS); 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 GridLayout(1, false)); // Create a horizontal slider, accepting the defaults new Slider(shell, SWT.HORIZONTAL); // Create a vertical slider and set its properties Slider slider = new Slider(shell, SWT.VERTICAL); slider.setMinimum(0);/*from w w w . ja va 2s. c om*/ slider.setMaximum(100); slider.setIncrement(5); slider.setPageIncrement(20); slider.setSelection(75); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:StyledTextVerifyListenerStopPasting.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER); styledText.setText("12345"); styledText.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent event) { if (event.text.length() > 1) { event.text = "Stop pasting!"; }//from w w w. j a v a 2s .c o m } }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GroupShadowCreate.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create the first Group Group group1 = new Group(shell, SWT.SHADOW_IN); group1.setText("Who's your favorite?"); group1.setLayout(new RowLayout(SWT.VERTICAL)); new Button(group1, SWT.RADIO).setText("A"); new Button(group1, SWT.RADIO).setText("B"); new Button(group1, SWT.RADIO).setText("C"); new Button(group1, SWT.RADIO).setText("D"); shell.open();//from w w w. j a v a2 s. c om while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ComboExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); // Create a drop-down combo Combo combo = new Combo(shell, SWT.DROP_DOWN); combo.setItems(ITEMS);//from ww w . j a v a 2 s.co m // Create a read only combo Combo readOnly = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY); readOnly.setItems(ITEMS); // Create a "simple" combo Combo simple = new Combo(shell, SWT.SIMPLE); simple.setItems(ITEMS); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:AccessibleControlListenerAdding.java
License:asdf
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Label label = new Label(shell, SWT.NONE); label.setText("asdf"); Accessible accessible = label.getAccessible(); accessible.addAccessibleControlListener(new AccessibleControlAdapter() { public void getState(AccessibleControlEvent e) { super.getState(e); System.out.println("AccessibleControlListener"); }//from www .j ava 2 s. c om }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ShellClosePrevent.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.addListener(SWT.Close, new Listener() { public void handleEvent(Event 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 ww w . j a v a 2 s. co m*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GroupImageAdding.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Group group = new Group(shell, SWT.NONE); group.setLayout(new FillLayout()); group.setText("a square"); Canvas canvas = new Canvas(group, SWT.NONE); canvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.drawImage(new Image(display, "yourFile.gif"), 0, 0); }/* ww w. j a va 2 s .com*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }