List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:EventTypeGet.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); Button button = new Button(shell, SWT.NONE); button.setText("Click and check the console"); button.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { System.out.println(getEventName(e.type)); switch (e.type) { case SWT.Selection: System.out.println("Button pressed"); break; }//from ww w .java 2 s. c om } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:Snippet45.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Scale scale = new Scale(shell, SWT.BORDER); scale.setSize(200, 64);//ww w. j a v a2 s .com scale.setMaximum(40); scale.setPageIncrement(5); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ImageLoadFromClassStream.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 = null;//from w ww. j av a 2 s. co m try { image = new Image(display, ImageLoadFromClassStream.class.getResourceAsStream("yourFile.gif")); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } e.gc.drawImage(image, 10, 10); image.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:TreeNodeDefaultSelectionListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Tree tree = new Tree(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); for (int i = 0; i < 4; i++) { TreeItem item0 = new TreeItem(tree, 0); item0.setText("Item " + i); for (int j = 0; j < 4; j++) { TreeItem item1 = new TreeItem(item0, 0); item1.setText("SubItem " + i + " " + j); for (int k = 0; k < 4; k++) { TreeItem item2 = new TreeItem(item1, 0); item2.setText("SubItem " + i + " " + j + " " + k); }/*w w w. j a va2 s. co m*/ } } tree.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { String string = ""; TreeItem[] selection = tree.getSelection(); for (int i = 0; i < selection.length; i++) string += selection[i] + " "; System.out.println("DefaultSelection={" + string + "}"); } }); tree.getItems()[0].setExpanded(true); 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) { final Display d = new Display(); final Shell shell = new Shell(d); shell.setSize(250, 200);/* w w w . ja v a2 s . com*/ final String RUN = "Press to Run"; final String IS_RUNNING = "Running..."; shell.setLayout(new FillLayout()); final Button button = new Button(shell, SWT.PUSH); button.setText(RUN); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { button.setText(IS_RUNNING); BusyIndicator.showWhile(button.getDisplay(), new SleepThread(1000)); button.setText(RUN); } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:StackLayoutTest.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); StackLayout layout = new StackLayout(); shell.setLayout(layout);/* w w w . j a v a 2 s . c o m*/ StackLayoutSelectionAdapter adapter = new StackLayoutSelectionAdapter(shell, layout); Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.addSelectionListener(adapter); Button two = new Button(shell, SWT.PUSH); two.setText("two"); two.addSelectionListener(adapter); Button three = new Button(shell, SWT.PUSH); three.setText("three"); three.addSelectionListener(adapter); layout.topControl = one; shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet72.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.open();/* w w w . j a v a 2 s . co m*/ FileDialog dialog = new FileDialog(shell, SWT.SAVE); dialog.setFilterNames(new String[] { "Batch Files", "All Files (*.*)" }); dialog.setFilterExtensions(new String[] { "*.bat", "*.*" }); // Windows // wild // cards dialog.setFilterPath("c:\\"); // Windows path dialog.setFileName("fred.bat"); System.out.println("Save to: " + dialog.open()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ImageCreateForLable.java
public static void main(String[] args) { Image image;/* w ww .j a v a2s . com*/ Image copy; Image disable; Image gray; Display display = new Display(); Shell shell = new Shell(display); shell.setText("Show Image Flags"); image = new Image(display, "yourFile.gif"); copy = new Image(display, image, SWT.IMAGE_COPY); disable = new Image(display, image, SWT.IMAGE_DISABLE); gray = new Image(display, image, SWT.IMAGE_GRAY); shell.setLayout(new FillLayout()); // Create labels to hold each image new Label(shell, SWT.NONE).setImage(image); new Label(shell, SWT.NONE).setImage(copy); new Label(shell, SWT.NONE).setImage(disable); new Label(shell, SWT.NONE).setImage(gray); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } image.dispose(); copy.dispose(); disable.dispose(); gray.dispose(); display.dispose(); }
From source file:Snippet184.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Spinner spinner = new Spinner(shell, SWT.BORDER); spinner.setMinimum(0);//from w w w .j a v a2 s. co m spinner.setMaximum(1000); spinner.setSelection(500); spinner.setIncrement(1); spinner.setPageIncrement(100); spinner.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FocusTraversal.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Composite composite1 = new Composite(shell, SWT.BORDER); composite1.setLayout(new RowLayout()); composite1.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); Button button1 = new Button(composite1, SWT.PUSH); button1.setText("Button1"); Button button3 = new Button(composite1, SWT.PUSH); button3.setText("Button3"); Button radioButton1 = new Button(composite1, SWT.RADIO); radioButton1.setText("radio-1"); Button radioButton2 = new Button(composite1, SWT.RADIO); radioButton2.setText("radio-2"); Composite composite2 = new Composite(shell, SWT.BORDER); composite2.setLayout(new RowLayout()); composite2.setBackground(display.getSystemColor(SWT.COLOR_GREEN)); Button button2 = new Button(composite2, SWT.PUSH); button2.setText("Button2"); Combo combo = new Combo(composite2, SWT.DROP_DOWN); combo.add("combo"); combo.select(0);//from ww w .ja va 2 s .c om composite1.setTabList(new Control[] { button1, button3 }); composite2.setTabList(new Control[] { button2, combo }); shell.setTabList(new Control[] { composite2, composite1 }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }