List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:TreeThreeLevel.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Tree tree = new Tree(shell, SWT.BORDER); for (int i = 0; i < 3; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("item " + i); for (int j = 0; j < 3; j++) { TreeItem subItem = new TreeItem(item, SWT.NONE); subItem.setText("item " + i + " " + j); for (int k = 0; k < 3; k++) { TreeItem subsubItem = new TreeItem(subItem, SWT.NONE); subsubItem.setText("item " + i + " " + j + " " + k); }//ww w .ja v a 2s .c om } } shell.setSize(400, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GridLayoutDefaultValues.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); GridLayout gridLayout = new GridLayout(); shell.setLayout(gridLayout);/*ww w . j a va 2s . c om*/ Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 200); 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(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); ProgressBar pb1 = new ProgressBar(shell, SWT.HORIZONTAL | SWT.SMOOTH); pb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); pb1.setMinimum(0);//from ww w . j a v a 2s . c o m pb1.setMaximum(30); new LongRunningOperation(display, pb1).start(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:TreeCreate.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); for (int i = 0; i < 4; i++) { TreeItem iItem = new TreeItem(tree, 0); iItem.setText("TreeItem (0) -" + i); for (int j = 0; j < 4; j++) { TreeItem jItem = new TreeItem(iItem, 0); jItem.setText("TreeItem (1) -" + j); for (int k = 0; k < 4; k++) { TreeItem kItem = new TreeItem(jItem, 0); kItem.setText("TreeItem (2) -" + k); for (int l = 0; l < 4; l++) { TreeItem lItem = new TreeItem(kItem, 0); lItem.setText("TreeItem (3) -" + l); for (int m = 0; m < 4; m++) { TreeItem mItem = new TreeItem(lItem, 0); mItem.setText("TreeItem (3) -" + l); }/*from w ww . ja v a 2 s .co m*/ } } } } shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:RowLayoutMargin.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.marginLeft = 20;//from ww w . j av a2s . c om rowLayout.marginRight = 20; rowLayout.marginTop = 20; rowLayout.marginBottom = 20; shell.setLayout(rowLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:DialogEmptyDisplay.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP); final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLayout(new RowLayout()); dialog.pack();/*from www . ja v a 2 s. c om*/ dialog.open(); // Move the dialog to the center of the top level shell. Rectangle shellBounds = shell.getBounds(); Point dialogSize = dialog.getSize(); dialog.setLocation(shellBounds.x + (shellBounds.width - dialogSize.x) / 2, shellBounds.y + (shellBounds.height - dialogSize.y) / 2); // 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:RowLayoutHorizontal.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout(SWT.HORIZONTAL)); 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"); new Button(shell, SWT.PUSH).setText("seven"); shell.open();/*from www. j av a 2 s . c om*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ListSelectionListenerAdd.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); final List list = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); for (int i = 0; i < 128; i++) { list.add("Item " + i); }//from ww w. j a v a 2s . c o m list.setBounds(0, 0, 100, 100); list.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { String string = ""; int[] selection = list.getSelectionIndices(); for (int i = 0; i < selection.length; i++) { string += selection[i] + " "; } System.out.println("Selection={" + string + "}"); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:LineJoinStyleBevelMiterRound.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { int x = 20, y = 20, w = 120, h = 60; GC gc = event.gc;/*from w w w . jav a 2s .c om*/ gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); gc.setLineWidth(10); int[] joins = { SWT.JOIN_BEVEL, SWT.JOIN_MITER, SWT.JOIN_ROUND }; for (int i = 0; i < joins.length; i++) { gc.setLineJoin(joins[i]); gc.drawPolygon(new int[] { x, y, x + w / 2, y + h, x + w, y }); y += h + 20; } } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FileDialogMultipleFileNameSelection.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); FileDialog dlg = new FileDialog(shell, SWT.MULTI); Collection files = new ArrayList(); if (dlg.open() != null) { String[] names = dlg.getFileNames(); for (int i = 0, n = names.length; i < n; i++) { StringBuffer buf = new StringBuffer(dlg.getFilterPath()); if (buf.charAt(buf.length() - 1) != File.separatorChar) buf.append(File.separatorChar); buf.append(names[i]);//from ww w . j a v a 2 s . c om files.add(buf.toString()); } } System.out.println(files); display.dispose(); }