List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
From source file:StyledTextModifyListener.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER); styledText.setText("12345"); styledText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { System.out.println("Character Count: " + styledText.getCharCount()); }/* ww w .j a va2 s .c o m*/ }); styledText.setBounds(10, 10, 100, 100); 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(); }/*from w ww . jav a 2 s . co m*/ 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);// w ww .j av a 2s . c om 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:org.eclipse.swt.snippets.Snippet302.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 302"); FillLayout layout = new FillLayout(); layout.marginHeight = 10;//from w ww . j a v a 2 s . c om layout.marginWidth = 10; shell.setLayout(layout); Tree tree = new Tree(shell, SWT.BORDER | SWT.NO_SCROLL); for (int i = 0; i < 10; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Item " + i); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FontSystemGettingSWT.java
public static void main(String[] args) { final 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.setFont(display.getSystemFont()); e.gc.drawText(display.getSystemFont().getFontData()[0].getName(), 5, 5); }/*w w w .j av a2 s .c o m*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:SelectionStartEnd.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Text text = new Text(shell, SWT.BORDER | SWT.V_SCROLL); text.setBounds(10, 10, 400, 100);//from w w w .j a v a2 s .c o m text.append("text text text text text text text text text text text text text "); shell.open(); text.setSelection(30, 38); System.out.println("selection=" + text.getSelection()); System.out.println("caret position=" + text.getCaretPosition()); System.out.println("caret location=" + text.getCaretLocation()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:SliderMinMaxValue.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // 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 www .j a v a 2 s.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:org.eclipse.swt.snippets.Snippet52.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 52"); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); Rectangle clientArea = shell.getClientArea(); table.setBounds(clientArea.x, clientArea.y, 200, 200); for (int i = 0; i < 128; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); }// ww w. ja v a 2 s .c o m table.setSelection(95); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet40.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Composite c1 = new Composite(shell, SWT.BORDER); c1.setSize(100, 100);// w w w. ja va 2s . co m Composite c2 = new Composite(shell, SWT.BORDER); c2.setBounds(100, 0, 100, 100); Menu menu = new Menu(shell, SWT.POP_UP); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("Popup"); c1.setMenu(menu); c2.setMenu(menu); shell.setMenu(menu); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet301.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 301"); FillLayout layout = new FillLayout(); layout.marginHeight = 10;/*from w ww.j av a 2 s .co m*/ layout.marginWidth = 10; shell.setLayout(layout); Table table = new Table(shell, SWT.BORDER | SWT.NO_SCROLL); for (int i = 0; i < 10; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }