List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
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 www.ja va2 s . co m shell.pack(); 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 . ja v a 2 s. c o m*/ return null; }); 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 w w w .j a v 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);/*w ww . ja v a 2s . c om*/ 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.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); }//from ww w . j a v a 2 s . co m 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: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);// w w w . j a v a 2s. co m sc.setContent(child); 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 .j a va 2 s . c o 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();/* www .j av a 2 s. c om*/ 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);//from w w w. j a v a 2 s . c om 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(); }
From source file:Snippet183.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Link link = new Link(shell, SWT.NONE); String text = "The SWT component is designed to provide <a>efficient</a>, <a>portable</a> <a href=\"native\">access to the user-interface facilities of the operating systems</a> on which it is implemented."; link.setText(text);//ww w .j a v a 2 s .c o m link.setSize(400, 400); link.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { System.out.println("Selection: " + event.text); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }