List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
From source file:org.eclipse.swt.snippets.Snippet260.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setText("WebKit"); final Browser browser; try {//from w w w . j ava2s . com browser = new Browser(shell, SWT.WEBKIT); } catch (SWTError e) { System.out.println("Could not instantiate Browser: " + e.getMessage()); display.dispose(); return; } shell.open(); browser.setUrl("https://webkit.org/"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:SashFormOri.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.setOrientation(SWT.HORIZONTAL); shell.open();/*w w w .j av a 2 s.c om*/ 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 w w w . j a v a2 s .co 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:Snippet100.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(10, 10, 200, 200);//from ww w . j ava2 s . c om Text text = new Text(shell, SWT.MULTI); text.setBounds(10, 10, 150, 150); Font initialFont = text.getFont(); FontData[] fontData = initialFont.getFontData(); for (int i = 0; i < fontData.length; i++) { fontData[i].setHeight(24); } Font newFont = new Font(display, fontData); text.setFont(newFont); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } newFont.dispose(); display.dispose(); }
From source file:RowLayoutHorizontal.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout(SWT.HORIZONTAL)); 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"); new Button(shell, SWT.PUSH).setText("seven"); shell.open();//from ww w . ja va 2s. co m 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 . j a va 2s . co m } tabFolder.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GCColorChange.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) { e.gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); e.gc.drawText("I'm in blue!", 20, 20); }//from w ww. ja v a 2 s. c om }); 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 www . 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:MainClass.java
public static void main(String[] a) { Display display = new Display(); // Create the main window Shell shell = new Shell(display); Text fahrenheit = new Text(shell, SWT.BORDER); fahrenheit.setData("Type a temperature in Fahrenheit"); fahrenheit.setBounds(20, 20, 100, 20); fahrenheit.addHelpListener(new HelpListener() { public void helpRequested(HelpEvent event) { System.out.println((String) event.widget.getData()); }/*from www . j a v a2 s . co m*/ }); 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 . java 2s .co m*/ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }