List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
From source file:PaintAWTInsideSWT.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.EMBEDDED); Frame frame = SWT_AWT.new_Frame(composite); Canvas canvas = new Canvas() { public void paint(Graphics g) { Dimension d = getSize(); g.drawLine(0, 0, d.width, d.height); }/*from www.ja va 2s . c o m*/ }; frame.add(canvas); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TabFolderTabItem.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); 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);// ww w . java 2 s . c om } tabFolder.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet284.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("URLTransfer"); shell.setLayout(new FillLayout()); final Label label1 = new Label(shell, SWT.BORDER); label1.setText("http://www.eclipse.org"); final Label label2 = new Label(shell, SWT.BORDER); setDragSource(label1);// www.ja v a 2s . c om setDropTarget(label2); shell.setSize(600, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ShellControlsGetting.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); }/* w w w. j a v a 2s .c o m*/ Control[] children = shell.getChildren(); for (int i = 0; i < children.length; i++) { Control child = children[i]; System.out.println(child); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:DrawArcSWT.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.setBackground(e.display.getSystemColor(SWT.COLOR_BLACK)); e.gc.fillArc(200, 100, 500, 400, 30, 40); }//from ww w.jav a2s . com }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:CTabFolderAddCTabItem.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); CTabFolder folder = new CTabFolder(shell, SWT.BORDER); for (int i = 0; i < 4; i++) { CTabItem item = new CTabItem(folder, SWT.CLOSE); item.setText("Item " + i); Text text = new Text(folder, SWT.MULTI); text.setText("Content for Item " + i); item.setControl(text);/*from w ww . j a va 2 s.com*/ } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:StyledTextVerifyKeyListener.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.addVerifyKeyListener(new VerifyKeyListener() { public void verifyKey(VerifyEvent e) { System.out.println(e.character); e.doit = false;// w w w . j a v a2s . co m } }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet351.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 ww w . jav a 2 s. c o m*/ 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("http://webkit.org"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TableItemGetIndex.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200);/*from w ww.j av a2 s. c om*/ for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } TableItem item = new TableItem(table, SWT.NONE, 5); item.setText(" New Item "); System.out.println(table.indexOf(item)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:DrawingProcessNewLine.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.drawText("www.\njava2s\t.com", 5, 5, true); e.gc.drawText("www.\njava2s\t.com", 5, 55, false); }//from w ww . j a v a 2 s . c om }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }