List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:GenericEventUntyped.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.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { System.out.println("widgetSelected"); }//from ww w . j a va 2s. co m public void widgetDefaultSelected(SelectionEvent arg0) { System.out.println("widgetDefaultSelected"); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:DrawingProcessNewLine.java
public static void main(String[] args) { final 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.drawText("www.\njava2s\t.com", 5, 5, true); e.gc.drawText("www.\njava2s\t.com", 5, 55, false); }/*w ww . j a v a 2s. c om*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FormLayoutLeftRight.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); FormData formData = new FormData(); formData.left = new FormAttachment(20); formData.top = new FormAttachment(20); button1.setLayoutData(formData);//ww w.j av a2 s. c o m shell.pack(); shell.open(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Shell shell = new Shell(new Display()); final Shell dialog = new Shell(shell, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM); dialog.setText("Delete File"); dialog.setSize(250, 150);//w ww .ja v a 2 s. com final Button buttonOK = new Button(dialog, SWT.PUSH); buttonOK.setText("OK"); buttonOK.setBounds(20, 55, 80, 25); Button buttonCancel = new Button(dialog, SWT.PUSH); buttonCancel.setText("Cancel"); buttonCancel.setBounds(120, 55, 80, 25); final Label label = new Label(dialog, SWT.NONE); label.setText("Delete the file?"); label.setBounds(20, 15, 100, 20); Listener listener = new Listener() { public void handleEvent(Event event) { if (event.widget == buttonOK) { System.out.println("OK"); } else { System.out.println("Cancel"); } dialog.close(); } }; buttonOK.addListener(SWT.Selection, listener); buttonCancel.addListener(SWT.Selection, listener); dialog.open(); }
From source file:TableDefaultSelectionListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); for (int i = 0; i < 16; i++) { TableItem item = new TableItem(table, 0); item.setText("Item " + i); }//w ww . j a v a 2 s.c om table.setBounds(0, 0, 100, 100); table.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { String string = ""; TableItem[] selection = table.getSelection(); for (int i = 0; i < selection.length; i++) string += selection[i] + " "; System.out.println("DefaultSelection={" + string + "}"); } }); 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 s = new Shell(d); s.setSize(250, 200);//from w ww . j av a 2s . c om s.setText("A Table Shell Example"); s.setLayout(new FillLayout()); Table t = new Table(s, SWT.BORDER); TableColumn tc1 = new TableColumn(t, SWT.CENTER); TableColumn tc2 = new TableColumn(t, SWT.CENTER); TableColumn tc3 = new TableColumn(t, SWT.CENTER); tc1.setText("First Name"); tc2.setText("Last Name"); tc3.setText("Address"); tc1.setWidth(70); tc2.setWidth(70); tc3.setWidth(80); t.setHeaderVisible(true); TableItem item1 = new TableItem(t, SWT.NONE); item1.setText(new String[] { "A", "B", "Address 1" }); TableItem item2 = new TableItem(t, SWT.NONE); item2.setText(new String[] { "C", "D", "Address 2" }); TableItem item3 = new TableItem(t, SWT.NONE); item3.setText(new String[] { "E", "F", "Address 3" }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:FontSystemGettingSWT.java
public static void main(String[] args) { final 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.setFont(display.getSystemFont()); e.gc.drawText(display.getSystemFont().getFontData()[0].getName(), 5, 5); }//w w w. j a va 2s .co m }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:CLabelGradientBackgroundThreeColors.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("CLabel Gradient"); shell.setLayout(new GridLayout(1, false)); CLabel one = new CLabel(shell, SWT.LEFT); one.setText("Second Gradient Example"); one.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Set the background gradient one.setBackground(new Color[] { shell.getDisplay().getSystemColor(SWT.COLOR_WHITE), shell.getDisplay().getSystemColor(SWT.COLOR_GRAY), shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY), shell.getDisplay().getSystemColor(SWT.COLOR_BLACK) }, new int[] { 33, 67, 100 }); shell.open();/*from w ww.j a va2 s .com*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutTest.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); RowLayout layout = new RowLayout(SWT.VERTICAL); layout.marginLeft = 12;/*from w ww. j a va 2 s . c om*/ layout.marginTop = 0; layout.justify = true; shell.setLayout(layout); new Button(shell, SWT.PUSH).setText("one"); new Button(shell, SWT.PUSH).setText("two"); new Button(shell, SWT.PUSH).setText("three"); new Button(shell, SWT.PUSH).setText("four"); new Button(shell, SWT.PUSH).setText("five"); new Button(shell, SWT.PUSH).setText("six"); Button b = new Button(shell, SWT.PUSH); b.setText("seven"); b.setLayoutData(new RowData(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 www . j av a2s. com 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(); }