List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
From source file:MainClass.java
public static void main(String[] a) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setSize(250, 200);//from w w w . j a v a 2 s. c o m 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.setFont(new Font(display, "Helvetica", 18, SWT.NORMAL)); e.gc.drawText("www.java2s.com", 0, 0); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TabItemSelection.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);/*from w ww . j a v a2 s. c o m*/ } tabFolder.setSelection(2); tabFolder.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display d = new Display(); Shell s = new Shell(d); s.setText("A Shell Menu Example"); Menu m = new Menu(s, SWT.BAR); MenuItem file = new MenuItem(m, SWT.CASCADE); file.setText("File"); Menu filemenu = new Menu(s, SWT.DROP_DOWN); file.setMenu(filemenu);/* www . j a va 2 s . c o m*/ MenuItem openItem = new MenuItem(filemenu, SWT.PUSH); openItem.setText("Open"); MenuItem exitItem = new MenuItem(filemenu, SWT.PUSH); exitItem.setText("Exit"); s.setMenuBar(m); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:CompositePaintListener.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL); final Composite composite = new Composite(shell, SWT.BORDER); composite.setSize(700, 600);//from w w w . j a v a 2 s . c o m final Color red = display.getSystemColor(SWT.COLOR_RED); composite.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.setBackground(red); e.gc.fillOval(5, 5, 690, 590); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet32.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.NONE); label.setText("Can't find icon for .bmp"); Image image = null;/*w w w .ja va 2 s . 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:EventListenerGeneral.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.SHADOW_IN | SWT.CENTER); shell.setLayout(new GridLayout()); Listener listener = new MouseEnterExitListener(); label.setText("Point your cursor here ..."); label.setBounds(30, 30, 200, 30);// w ww .j a v a2 s . c o m label.addListener(SWT.MouseEnter, listener); label.addListener(SWT.MouseExit, listener); shell.setSize(260, 120); shell.open(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:StyledTextIndentAlignmentJustify.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER); styledText.setText(text);/*from ww w .j av a 2 s . c om*/ styledText.setLineIndent(0, 1, 50); styledText.setLineAlignment(2, 1, SWT.CENTER); styledText.setLineJustify(4, 1, true); styledText.setLineAlignment(6, 1, SWT.RIGHT); styledText.setLineJustify(6, 1, true); shell.setSize(300, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:BrowserLocationListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Browser browser = new Browser(shell, SWT.NONE); browser.setBounds(5, 5, 600, 600);/*from w w w. j av a 2s. c o m*/ browser.addLocationListener(new LocationListener() { public void changed(LocationEvent event) { if (event.top) System.out.println(event.location); } public void changing(LocationEvent event) { } }); browser.setUrl("http://java2s.com"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ScrollBarSelectionValue.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a List with a vertical ScrollBar List list = new List(shell, SWT.V_SCROLL); // Add a bunch of items to it for (int i = 0; i < 500; i++) { list.add("A list item"); }/*from w w w . j a v a 2 s . c o m*/ // Get the ScrollBar ScrollBar sb = list.getVerticalBar(); // Show the selection value System.out.println("Selection: " + sb.getSelection()); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet20.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); CoolBar bar = new CoolBar(shell, SWT.BORDER); for (int i = 0; i < 2; i++) { CoolItem item = new CoolItem(bar, SWT.NONE); Button button = new Button(bar, SWT.PUSH); button.setText("Button " + i); Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT); item.setPreferredSize(item.computeSize(size.x, size.y)); item.setControl(button);//from w w w . jav a 2s .co m } bar.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }