List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
From source file:DateTimeDialogCreate.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); DateTime calendar = new DateTime(shell, SWT.CALENDAR); calendar.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { System.out.println("calendar date changed"); }//from w w w.j ava 2s . c o m }); DateTime time = new DateTime(shell, SWT.TIME); time.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { System.out.println("time changed"); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ImageGrayScale.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) { Image image = new Image(display, "yourFile.gif"); Image disable = new Image(display, image, SWT.IMAGE_GRAY); e.gc.drawImage(disable, 10, 10); e.gc.drawImage(image, 10, 50); image.dispose();/*from w ww. j a va 2s. co m*/ disable.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet20.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 20"); 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 . j a va 2s .c o m*/ } Rectangle clientArea = shell.getClientArea(); bar.setLocation(clientArea.x, clientArea.y); bar.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ImageDisable.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) { Image image = new Image(display, "yourFile.gif"); Image disable = new Image(display, image, SWT.IMAGE_DISABLE); e.gc.drawImage(disable, 10, 10); e.gc.drawImage(image, 10, 50); image.dispose();//from w ww . j a va 2s . c om disable.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ImageDataManipuatation.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) { Image image = new Image(display, "yourFile.gif"); ImageData data = image.getImageData(); data.setPixel(5, 5, 5);//ww w .j ava2 s .com Image anotherImage = new Image(display, data); e.gc.drawImage(anotherImage, 10, 10); image.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:StyledTextVerifyListenerBackspaceDelete.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 event) { System.out.println(event.character); event.doit = false;// w ww .j a va2 s.c o m // Allow backspace and delete if (event.character == '\u0008' || event.character == '\u007F') { event.doit = true; } } }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:SWTButtonExampleDemo.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setSize(300, 200);// w w w . j ava2s . c o m shell.setText("Button Example"); shell.setLayout(new RowLayout()); final Button button = new Button(shell, SWT.PUSH); button.setText("Click Me"); final Text text = new Text(shell, SWT.SHADOW_IN); button.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { text.setText("No worries!"); } public void widgetDefaultSelected(SelectionEvent event) { text.setText("No worries!"); } }); 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(); final Shell s = new Shell(d); s.setSize(250, 200);/*from w w w. ja va 2 s. co m*/ s.setText("A MouseListener Example"); s.open(); s.addMouseListener(new MouseListener() { public void mouseDown(MouseEvent e) { System.out.println("Mouse Button Down at:" + e.x + " " + e.y); } public void mouseUp(MouseEvent e) { System.out.println("Mouse Button up at:" + e.x + " " + e.y); System.out.println(e.button); } public void mouseDoubleClick(MouseEvent e) { System.out.println("Mouse Double Clicked at:" + e.x + " " + e.y); } }); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:ControlTabTransversing.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Text text1 = new Text(shell, SWT.SINGLE | SWT.BORDER); text1.setText("Can't Traverse"); text1.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: { e.doit = false;/*from www . j a v a2s .c o m*/ } } } }); Text text2 = new Text(shell, SWT.SINGLE | SWT.BORDER); text2.setText("Can Traverse"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet4.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 4"); Button b = new Button(shell, SWT.PUSH); b.setText("Open Dialog ..."); b.pack();/*from w w w .ja v a 2 s. c o m*/ Rectangle clientArea = shell.getClientArea(); b.setLocation(clientArea.x + 10, clientArea.y + 10); b.addSelectionListener(widgetSelectedAdapter(e -> { Shell dialog = new Shell(shell, SWT.DIALOG_TRIM); dialog.addListener(SWT.Traverse, t -> { if (t.detail == SWT.TRAVERSE_ESCAPE) { t.doit = false; } }); dialog.open(); })); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }