List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
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[] { "A-1", "B-1", "C-1" }); combo.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { System.out.println(e.widget + " - Default Selection"); }//from w w w. 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:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION); for (int i = 0; i < 5; i++) { TableColumn column = new TableColumn(table, SWT.NONE); }/*from www. j a v a 2 s .com*/ for (int i = 0; i < 10; i++) { TableItem item = new TableItem(table, SWT.NONE); for (int j = 0; j < 5; j++) { item.setText(j, "Row " + i + ", Column " + j); } } for (int i = 0, n = table.getColumnCount(); i < n; i++) { table.getColumn(i).pack(); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:CTabFolderAddCTabItem.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); CTabFolder folder = new CTabFolder(shell, SWT.BORDER); for (int i = 0; i < 4; i++) { CTabItem item = new CTabItem(folder, SWT.CLOSE); item.setText("Item " + i); Text text = new Text(folder, SWT.MULTI); text.setText("Content for Item " + i); item.setControl(text);//from w w w .ja v a 2 s.c om } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:StyledTextVerifyListenerReturn.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER); styledText.setText("12345"); styledText.addVerifyKeyListener(new VerifyKeyListener() { public void verifyKey(VerifyEvent event) { System.out.println(event.character); event.doit = false;//from ww w . j av a 2 s. c om // Allow return if (event.character == '\r') event.doit = true; } }); styledText.setBounds(10, 10, 100, 100); 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);/*from w w w . j a va 2s . c om*/ shell.setLayout(new FillLayout()); Canvas drawingCanvas = new Canvas(shell, SWT.NONE); drawingCanvas.addPaintListener(new ArcExamplePaintListener()); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:FillRectangle.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.setBackground(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.fillRectangle(30, 40, 400, 200); }// w w w . j av a2s .co m }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ImageRegistryUsing.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(); shell.setLayout(new GridLayout(1, false)); ImageRegistry ir = new ImageRegistry(); ir.put("image1", new Image(display, "yourFile.gif")); Button executeButton = new Button(shell, SWT.PUSH); executeButton.setText("Execute"); executeButton.setImage(ir.get("image1")); shell.open();//from www.j ava2s . c om while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GCFromEvent.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); e.gc.drawText("You can draw text directly on a canvas", 60, 60); }//w w w.j a v a 2 s . co m }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:VerifyListenerUsing.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("Type somthing to verify."); text.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent arg0) { System.out.println("verifying"); }/*from w w w . j a va 2 s .c o m*/ }); 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()); // Create the first group Group group1 = new Group(shell, SWT.SHADOW_IN); group1.setText("Who's your favorite?"); group1.setLayout(new RowLayout(SWT.VERTICAL)); new Button(group1, SWT.RADIO).setText("A"); new Button(group1, SWT.RADIO).setText("B"); new Button(group1, SWT.RADIO).setText("C"); new Button(group1, SWT.RADIO).setText("D"); // 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("1"); new Button(group2, SWT.RADIO).setText("2"); new Button(group2, SWT.RADIO).setText("3"); shell.open();// w w w . j a va 2s .c o m while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }