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:TabItemWithToolTipImage.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); item.setToolTipText("This is my tab" + i); item.setImage(new Image(display, "yourFile.gif")); Button button = new Button(tabFolder, SWT.PUSH); button.setText("Page " + i); item.setControl(button);/*from w w w . j a v a 2 s .c o m*/ } tabFolder.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ToolItemDropDownMenu.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); ToolBar toolBar = new ToolBar(shell, SWT.BORDER | SWT.VERTICAL); ToolItem item = new ToolItem(toolBar, SWT.DROP_DOWN); item.setText("One"); DropdownSelectionListener listenerOne = new DropdownSelectionListener(item); listenerOne.add("Option One for One"); listenerOne.add("Option Two for One"); listenerOne.add("Option Three for One"); item.addSelectionListener(listenerOne); toolBar.pack();//from w ww.j a va 2s .c om shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:StyledTextThrowEAway.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.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent event) { // If the text contains E or e, throw it all away if (event.text.indexOf('e') > -1 || event.text.indexOf('E') > -1) { event.text = ""; }/*from ww w . j av a2 s.co m*/ } }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ComboGetText.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); String[] ITEMS = { "A", "B", "C", "D" }; final Combo combo = new Combo(shell, SWT.DROP_DOWN); combo.setItems(ITEMS);/*from w w w. ja va2 s . c o m*/ combo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { System.out.println(combo.getText()); } public void widgetDefaultSelected(SelectionEvent e) { System.out.println(combo.getText()); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet368.java
public static void main(String[] args) throws Exception { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 368"); shell.setLayout(new FillLayout()); shell.setText("Customize line spacing provider"); StyledText text = new StyledText(shell, SWT.BORDER | SWT.V_SCROLL); text.setText("a\nb\nc\nd"); text.setLineSpacingProvider(lineIndex -> { if (lineIndex == 0) { return 10; } else if (lineIndex == 1) { return 30; }/* w ww.jav a 2s.c om*/ return null; }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ScrollCompisiteHoriVertical.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SashForm Test"); shell.setLayout(new FillLayout()); // Create the ScrolledComposite to scroll horizontally and vertically ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite child = new Composite(sc, SWT.NONE); child.setLayout(new FillLayout()); new Button(child, SWT.PUSH).setText("One"); new Button(child, SWT.PUSH).setText("Two"); child.setSize(400, 400);//from ww w. jav a 2 s .c o m sc.setContent(child); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet101.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 101"); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); Rectangle clientArea = shell.getClientArea(); table.setBounds(clientArea.x, clientArea.y, 200, 200); for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); }/* w w w . j av a2 s .com*/ TableItem item = new TableItem(table, SWT.NONE, 1); item.setText("*** New Item " + table.indexOf(item) + " ***"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet34.java
public static void main(String[] args) { Display display = new Display(); Image image = new Image(display, 16, 16); Color color = display.getSystemColor(SWT.COLOR_RED); GC gc = new GC(image); gc.setBackground(color);/*from w ww . jav a2 s . co m*/ gc.fillRectangle(image.getBounds()); gc.dispose(); Shell shell = new Shell(display); shell.setText("Snippet 34"); Label label = new Label(shell, SWT.BORDER); Rectangle clientArea = shell.getClientArea(); label.setLocation(clientArea.x, clientArea.y); label.setImage(image); label.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet248.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 248"); shell.setLayout(new FillLayout()); shell.addListener(SWT.Traverse, event -> { switch (event.detail) { case SWT.TRAVERSE_ESCAPE: shell.close();/*from w w w.ja v a 2 s . c o m*/ event.detail = SWT.TRAVERSE_NONE; event.doit = false; break; } }); Button button = new Button(shell, SWT.PUSH); button.setText("A Button (that doesn't process Escape)"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:EmbedSwingAWTSWT.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("SWT and Swing/AWT Example"); Composite treeComp = new Composite(shell, SWT.EMBEDDED); treeComp.setBounds(5, 5, 300, 300);// ww w.jav a2 s . c o m java.awt.Frame fileTableFrame = SWT_AWT.new_Frame(treeComp); java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout()); fileTableFrame.add(panel); JTree fileTable = new JTree(); fileTable.setDoubleBuffered(true); JScrollPane scrollPane = new JScrollPane(fileTable); panel.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }