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 display = new Display(); Shell shell = new Shell(display); shell.setText("Sash One"); // The SWT.BORDER style Decorations d = new Decorations(shell, SWT.ON_TOP); d.setLayoutData(new GridData(GridData.FILL_BOTH)); d.setLayout(new FillLayout()); Label l = new Label(d, SWT.CENTER); l.setText("SWT.ON_TOP"); d.setBounds(20, 20, 100, 100);/* www . j ava 2 s . c o m*/ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ListItemSelection.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a single-selection list List single = new List(shell, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); // Add the items, one by one for (int i = 0, n = ITEMS.length; i < n; i++) { single.add(ITEMS[i]);/*w w w . jav a 2 s .com*/ } // Select the third item single.select(2); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:CanvasRepaint.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.drawRoundRectangle(10, 10, 200, 200, 30, 30); }//w w w.j a va2s. co m }); canvas.redraw(); 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.setText("Sash One"); // The SWT.BORDER style Decorations d = new Decorations(shell, SWT.NO_TRIM); d.setLayoutData(new GridData(GridData.FILL_BOTH)); d.setLayout(new FillLayout()); Label l = new Label(d, SWT.CENTER); l.setText("SWT.NO_TRIM"); d.setBounds(20, 20, 100, 100);/* w w w .j a v a 2s .c om*/ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:SashExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); final Sash sash = new Sash(shell, SWT.BORDER | SWT.VERTICAL); sash.setBounds(10, 10, 15, 60);// w w w . ja v a 2s. co m sash.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { System.out.println("Selected. "); sash.setBounds(e.x, e.y, e.width, e.height); } }); shell.open(); sash.setFocus(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ComboSelectionListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Combo combo = new Combo(shell, SWT.NONE); combo.setItems(new String[] { "A-1", "B-1", "C-1" }); combo.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { System.out.println(e.widget + " - Default Selection"); }/*from w ww. jav a 2 s . c o m*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TextForeground.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); StyledText text = new StyledText(shell, SWT.BORDER); text.setText("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); StyleRange style1 = new StyleRange(); style1.start = 0;//w w w .j av a 2 s .co m style1.length = 10; style1.foreground = display.getSystemColor(SWT.COLOR_RED); text.setStyleRange(style1); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TextBackground.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); StyledText text = new StyledText(shell, SWT.BORDER); text.setText("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); StyleRange style1 = new StyleRange(); style1.start = 0;/*from ww w. ja va 2s. com*/ style1.length = 10; style1.background = display.getSystemColor(SWT.COLOR_BLUE); text.setStyleRange(style1); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ComboSelectionListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Combo combo = new Combo(shell, SWT.NONE); combo.setItems(new String[] { "Press enter to select", "B-1", "C-1" }); combo.addSelectionListener(new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { System.out.println("Combo"); }/* ww w . j a v a 2 s . c o m*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:LinkControlEventSelection.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Link link = new Link(shell, SWT.BORDER); link.setText("This a very simple <A href=\"htpp://www.java2s.com\">link</A> widget."); link.setSize(140, 40);/* w w w. j ava 2s. c o m*/ link.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { System.out.println("Selection: " + event.text); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }