List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
From source file:TextBackground.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;// w ww.j a v a 2 s . c o m style1.length = 10; style1.background = display.getSystemColor(SWT.COLOR_BLUE); 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); }// w w w. j a va 2 s . c om }); shell.open(); 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[] { "Press enter to select", "B-1", "C-1" }); combo.addSelectionListener(new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { System.out.println("Combo"); }/*from w ww . j a va 2s.co m*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:LinkControlEventSelection.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Link link = new Link(shell, SWT.BORDER); link.setText("This a very simple <A href=\"htpp://www.java2s.com\">link</A> widget."); link.setSize(140, 40);//from w ww. j a v a2 s . c om 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(); }
From source file:Snippet101.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200);/*from w w w.j av a2 s .co m*/ for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } 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:MouseTrackAdapter.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()); MouseTrackAdapter listener = new MouseEnterExitListener(); label.setText("Point your cursor here ..."); label.setBounds(30, 30, 200, 30);/*ww w .j a v a 2 s. c o m*/ label.addMouseTrackListener(listener); shell.setSize(260, 120); shell.open(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:org.eclipse.swt.snippets.Snippet44.java
public static void main(String[] args) { Display display = new Display(); final Cursor cursor = display.getSystemCursor(SWT.CURSOR_HAND); Shell shell = new Shell(display); shell.setText("Snippet 44"); shell.open();/*www . j a v a 2 s . c o m*/ final Button b = new Button(shell, 0); b.setText("Push to set cursor to hand"); Rectangle clientArea = shell.getClientArea(); b.setBounds(clientArea.x + 10, clientArea.y + 10, 200, 200); b.addListener(SWT.Selection, e -> b.setCursor(cursor)); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GroupWithoutGroupingRadioButtons.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create the second Group Group group2 = new Group(shell, SWT.NO_RADIO_GROUP); group2.setText("Who's your favorite?"); group2.setLayout(new RowLayout(SWT.VERTICAL)); new Button(group2, SWT.RADIO).setText("A"); new Button(group2, SWT.RADIO).setText("B"); new Button(group2, SWT.RADIO).setText("C"); shell.open();// w w w . ja v a 2 s .c om while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet41.java
public static void main(String[] args) { String string = "This is a string\nwith a new line."; Display display = new Display(); Shell shell = new Shell(display); shell.open();//from ww w .java 2 s . c om TabFolder folder = new TabFolder(shell, SWT.BORDER); folder.setSize(200, 200); TabItem item0 = new TabItem(folder, 0); item0.setToolTipText(string); ToolBar bar = new ToolBar(shell, SWT.BORDER); bar.setBounds(0, 200, 200, 64); ToolItem item1 = new ToolItem(bar, 0); item1.setToolTipText(string); shell.setToolTipText(string); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:DrawFocusRectangle.java
public static void main(String[] args) { Display display = new Display(); 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) { e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.drawFocus(5, 5, 200, 10); }//from ww w. j a v a2 s . c om }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }