List of usage examples for org.eclipse.swt.widgets Display readAndDispatch
public boolean readAndDispatch()
true
if there is potentially more work to do, or false
if the caller can sleep until another event is placed on the event queue. From source file:FormLayoutFormData.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); FormLayout layout = new FormLayout(); layout.marginHeight = 5;/*ww w .j a v a 2 s . c o m*/ layout.marginWidth = 10; shell.setLayout(layout); Button button = new Button(shell, SWT.PUSH); button.setText("Button"); FormData data = new FormData(); data.height = 50; data.width = 50; button.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet120.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 120"); shell.setSize(200, 200);// ww w . j a va2 s . c o m Monitor primary = display.getPrimaryMonitor(); Rectangle bounds = primary.getBounds(); Rectangle rect = shell.getBounds(); int x = bounds.x + (bounds.width - rect.width) / 2; int y = bounds.y + (bounds.height - rect.height) / 2; shell.setLocation(x, y); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet54.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 54"); shell.setSize(400, 300);/* w w w . j a va2 s .co m*/ final Sash sash = new Sash(shell, SWT.BORDER | SWT.VERTICAL); Rectangle clientArea = shell.getClientArea(); sash.setBounds(180, clientArea.y, 32, clientArea.height); sash.addListener(SWT.Selection, e -> sash.setBounds(e.x, e.y, e.width, e.height)); shell.open(); sash.setFocus(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FontLargerCreate.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Text text = new Text(shell, SWT.MULTI | SWT.BORDER); text.setBounds(10, 10, 150, 150);/* w w w .j a v a 2 s . c om*/ 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:ListScrollBottom.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"); }/* w w w. j ava 2 s . c om*/ // Scroll to the bottom list.select(list.getItemCount() - 1); list.showSelection(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ControlBounds.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Button button = new Button(shell, SWT.PUSH); button.setBounds(20, 20, 200, 20);//from w ww . ja v a 2 s. co m shell.setSize(260, 120); shell.open(); System.out.println("------------------------------"); System.out.println("getBounds: " + button.getBounds()); System.out.println("getLocation: " + button.getLocation()); System.out.println("getSize: " + button.getSize()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:SashExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); final Sash sash = new Sash(shell, SWT.BORDER | SWT.VERTICAL); sash.setBounds(10, 10, 15, 60);/*from w w w. ja v a2s . com*/ sash.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { System.out.println("Selected. "); sash.setBounds(e.x, e.y, e.width, e.height); } }); shell.open(); sash.setFocus(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ComboSelectionListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Combo combo = new Combo(shell, SWT.NONE); combo.setItems(new String[] { "A-1", "B-1", "C-1" }); combo.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { System.out.println(e.widget + " - Default Selection"); }/*from www .ja v a 2s . co m*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TextForeground.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); StyledText text = new StyledText(shell, SWT.BORDER); text.setText("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); StyleRange style1 = new StyleRange(); style1.start = 0;// ww w .j a va 2 s .c om style1.length = 10; style1.foreground = display.getSystemColor(SWT.COLOR_RED); text.setStyleRange(style1); 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 display = new Display(); // Create the main window Shell shell = new Shell(display); shell.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent event) { // Get the event source (the shell) Shell shell = (Shell) event.getSource(); Rectangle rect = shell.getClientArea(); System.out.println(rect); }/*from w w w . j a v a 2 s. co m*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }