List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:MainClass.java
public static void main(String[] a) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setSize(250, 200);/*from w w w. ja v a 2s.co m*/ shell.setLayout(new FillLayout()); // Create a canvas Canvas canvas = new Canvas(shell, SWT.NONE); canvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.setFont(new Font(display, "Helvetica", 18, SWT.NORMAL)); e.gc.drawText("www.java2s.com", 0, 0); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet182.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>link</A> widget."); link.setSize(140, 40);//from w w w. j av a 2 s . co m shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FontChangeSWT.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) { Font font = new Font(shell.getDisplay(), "Helvetica", 18, SWT.NORMAL); e.gc.setFont(font);//from w w w. j ava 2s . co m e.gc.drawText("My Text", 0, 0); font.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ButtonExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(3, true)); // Create three push buttons new Button(shell, SWT.PUSH).setText("Push 1"); new Button(shell, SWT.PUSH).setText("Push 2"); new Button(shell, SWT.PUSH).setText("Push 3"); // Create three checkboxes new Button(shell, SWT.CHECK).setText("Checkbox 1"); new Button(shell, SWT.CHECK).setText("Checkbox 2"); new Button(shell, SWT.CHECK).setText("Checkbox 3"); // Create three toggle buttons new Button(shell, SWT.TOGGLE).setText("Toggle 1"); new Button(shell, SWT.TOGGLE).setText("Toggle 2"); new Button(shell, SWT.TOGGLE).setText("Toggle 3"); // Create three radio buttons new Button(shell, SWT.RADIO).setText("Radio 1"); new Button(shell, SWT.RADIO).setText("Radio 2"); new Button(shell, SWT.RADIO).setText("Radio 3"); // Create three flat buttons new Button(shell, SWT.FLAT).setText("Flat 1"); new Button(shell, SWT.FLAT).setText("Flat 2"); new Button(shell, SWT.FLAT).setText("Flat 3"); // Create three arrow buttons new Button(shell, SWT.ARROW); new Button(shell, SWT.ARROW | SWT.LEFT); new Button(shell, SWT.ARROW | SWT.DOWN); shell.pack();/* ww w .j a v a 2 s . c om*/ shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:TableColumnIcon.java
public static void main(String[] args) { final Display display = new Display(); final Image image = new Image(display, 16, 16); GC gc = new GC(image); gc.setBackground(display.getSystemColor(SWT.COLOR_RED)); gc.fillRectangle(image.getBounds()); gc.dispose();//from ww w . j a v a 2 s . com final Shell shell = new Shell(display); shell.setText("Lazy Table"); shell.setLayout(new FillLayout()); final Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200); for (int i = 0; i < 20; i++) { final int[] index = new int[] { i }; TableItem item = new TableItem(table, SWT.NONE); item.setText("Table Item " + index[0]); item.setImage(image); } shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); display.dispose(); }
From source file:ComboTraverseListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Text text = new Text(shell, SWT.SINGLE | SWT.BORDER); text.setText("Press TAB"); Combo combo = new Combo(shell, SWT.NONE); combo.setItems(new String[] { "Press enter to select", "B-1", "C-1" }); combo.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { System.out.println("keyTraversed"); }/*from w ww . j a v a 2 s.c o m*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:CTabFolderGradientBackground.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Show CTabFolder"); shell.setLayout(new GridLayout(1, true)); CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP); tabFolder.setBorderVisible(true);//from w ww . j av a2 s. c o m tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); // Set up a gradient background for the selected tab tabFolder.setSelectionBackground(new Color[] { display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW), display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW) }, new int[] { 50, 100 }); new CTabItem(tabFolder, SWT.NONE, 0).setText("Tab index 1 "); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:DecroationStyles.java
public static void main(String[] args) { Display display = new Display(); Shell composite = new Shell(display); composite.setText("Decorations Example"); composite.setLayout(new GridLayout(3, true)); // The SWT.BORDER style Decorations d = new Decorations(composite, SWT.BORDER); // d = new Decorations(composite, SWT.CLOSE); // d = new Decorations(composite, SWT.MIN); // d = new Decorations(composite, SWT.MAX); // d = new Decorations(composite, SWT.NO_TRIM); // d = new Decorations(composite, SWT.RESIZE); // d = new Decorations(composite, SWT.TITLE); // d = new Decorations(composite, SWT.ON_TOP); // d = new Decorations(composite, SWT.TOOL); d.setLayoutData(new GridData(GridData.FILL_BOTH)); d.setLayout(new FillLayout()); new Label(d, SWT.CENTER).setText("SWT.BORDER"); composite.open();/*w w w .ja v a 2s. c o m*/ while (!composite.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display d = new Display(); Shell s = new Shell(d); GridLayout gl = new GridLayout(); gl.numColumns = 4;// ww w .jav a2 s. c o m s.setLayout(gl); s.setSize(250, 275); s.setText("A Shell Composite Example"); s.setLayout(gl); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 4; gd = new GridData(); Composite c1 = new Composite(s, SWT.NO_FOCUS); gd = new GridData(GridData.FILL_HORIZONTAL); c1.setLayoutData(gd); Composite c2 = new Composite(s, SWT.NO_FOCUS); gd = new GridData(GridData.FILL_HORIZONTAL); c2.setLayoutData(gd); Composite c = new Composite(s, SWT.NO_FOCUS); c.setLayout(new RowLayout()); Button b1 = new Button(c, SWT.PUSH | SWT.BORDER); b1.setText("OK"); Button b2 = new Button(c, SWT.PUSH | SWT.BORDER); b2.setText("Cancel"); gd = new GridData(GridData.FILL_HORIZONTAL); c.setLayoutData(gd); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:ProgressBarExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); // Create a smooth progress bar ProgressBar pb1 = new ProgressBar(shell, SWT.HORIZONTAL | SWT.SMOOTH); pb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); pb1.setMinimum(0);//w ww .j a v a 2 s .com pb1.setMaximum(30); // Create an indeterminate progress bar ProgressBar pb2 = new ProgressBar(shell, SWT.HORIZONTAL | SWT.INDETERMINATE); pb2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Start the first progress bar new LongRunningOperation(display, pb1).start(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }