List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
From source file:RowLayoutType.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.type = SWT.VERTICAL;/* www. j a va2 s . c o m*/ shell.setLayout(rowLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FontChangeSWT.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) { Font font = new Font(shell.getDisplay(), "Helvetica", 18, SWT.NORMAL); e.gc.setFont(font);/*w w w . j av a2 s . c o m*/ e.gc.drawText("My Text", 0, 0); font.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet32.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 32"); Label label = new Label(shell, SWT.NONE); label.setText("Can't find icon for .bmp"); Image image = null;//w ww . j a v a 2s .c o m Program p = Program.findProgram(".bmp"); if (p != null) { ImageData data = p.getImageData(); if (data != null) { image = new Image(display, data); label.setImage(image); } } label.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (image != null) image.dispose(); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet39.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 39"); shell.setLayout(new GridLayout()); CCombo combo = new CCombo(shell, SWT.READ_ONLY | SWT.FLAT | SWT.BORDER); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); for (int i = 0; i < 5; i++) { combo.add("item" + i); }/* ww w. j a v a2 s . c o m*/ combo.setText("item0"); combo.addSelectionListener(widgetSelectedAdapter(e -> System.out.println("Item selected"))); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FormLayoutSingleLine.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.NONE | SWT.BORDER); label.setText("Name"); Text text = new Text(shell, SWT.NONE); FormLayout layout = new FormLayout(); layout.marginWidth = layout.marginHeight = 5; shell.setLayout(layout);/*from www. ja va 2s . c o m*/ FormData data = new FormData(200, SWT.DEFAULT); text.setLayoutData(data); data.left = new FormAttachment(label, 5); data.top = new FormAttachment(label, 0, SWT.CENTER); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet264.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Media Player Example"); shell.setLayout(new FillLayout()); try {// w w w. ja v a2 s . c o m OleFrame frame = new OleFrame(shell, SWT.NONE); clientSite = new OleClientSite(frame, SWT.NONE, "MPlayer"); addFileMenu(frame); } catch (SWTError e) { System.out.println("Unable to open activeX control"); display.dispose(); return; } shell.setSize(800, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GenericEventUntyped.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); Button button = new Button(shell, SWT.NONE); button.setText("Click and check the console"); button.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { System.out.println("widgetSelected"); }//from w w w . j ava 2s.c o m public void widgetDefaultSelected(SelectionEvent arg0) { System.out.println("widgetDefaultSelected"); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:RowLayoutRowData.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); shell.setLayout(rowLayout);/*from w w w . ja v a2 s . co m*/ Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); list.setLayoutData(new RowData(100, 35)); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.examples.layoutexample.LayoutExample.java
/** * Invokes as a standalone program.//from ww w . ja v a 2 s. co m */ public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); new LayoutExample(shell); shell.setText(getResourceString("window.title")); shell.addShellListener(ShellListener.shellClosedAdapter(e -> { Shell[] shells = display.getShells(); for (Shell currentShell : shells) { if (currentShell != shell) currentShell.close(); } })); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
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);//from w w w .j a v a 2s. com shell.setLayout(new FillLayout()); Text text = new Text(shell, SWT.BORDER); text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { switch (event.keyCode) { case SWT.CR: System.out.println(SWT.CR); case SWT.ESC: System.out.println(SWT.ESC); break; } } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }