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 d = new Display(); final Shell shell = new Shell(d); shell.setSize(250, 200);/*from w w w.j ava 2 s . c o 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.drawRoundRectangle(10, 10, 200, 200, 30, 60); } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:ButtonWithEventListener.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) { switch (e.type) { case SWT.Selection: System.out.println("Button pressed"); break; }//www . j a v a 2 s . c o m } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(); shell.setLayout(new GridLayout(1, false)); // Create a label new Label(shell, SWT.NONE).setText("This is a plain label."); // Create a vertical separator new Label(shell, SWT.SEPARATOR); // Create a label with a border new Label(shell, SWT.BORDER).setText("This is a label with a border."); // Create a horizontal separator Label separator = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR); separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // Create a label with an image // Image image = new Image(display, "interspatial.gif"); // Label imageLabel = new Label(shell, SWT.NONE); // imageLabel.setImage(image); shell.open();/*from w w w . j a va 2 s . c o m*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:DrawFocusRectangle.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); }/*from www . j a va2 s. c om*/ }); shell.open(); while (!shell.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); s.setSize(250, 250);//w ww .j a va 2s . c o m s.setText("A Slider Example"); final Slider slide = new Slider(s, SWT.HORIZONTAL); slide.setBounds(15, 50, 125, 15); slide.setMinimum(0); slide.setMaximum(100); slide.setIncrement(1); final Text t = new Text(s, SWT.BORDER); t.setBounds(115, 25, 25, 25); t.setText("0"); slide.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { t.setText(new Integer(slide.getSelection()).toString()); } }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:DrawStringLineTabSWT.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.drawString("www.\njava2s\t.com", 5, 5); }/*from w w w .j a v a 2 s . c o m*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:StyledTextExtendedModifyListener.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER); styledText.setText("12345"); styledText.addExtendedModifyListener(new ExtendedModifyListener() { public void modifyText(ExtendedModifyEvent event) { System.out.println(event.start); System.out.println(event.length); System.out.println(event.replacedText); }//from ww w . j a va 2 s . c om }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:TreeNodeSelection.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Tree tree = new Tree(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); for (int i = 0; i < 12; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Item " + i); for (int l = 0; l < 12; l++) { TreeItem litem = new TreeItem(item, SWT.NONE); litem.setText("Item " + i); }/*from ww w . ja v a 2s .c o m*/ } tree.setSize(100, 100); tree.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { String string = event.detail == SWT.CHECK ? "Checked" : "Selected"; System.out.println(event.item + " " + string); } }); shell.setSize(200, 200); 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 . j a v a 2 s .c om 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.setForeground(e.display.getSystemColor(SWT.COLOR_BLACK)); e.gc.drawOval(100, 20, 100, 50); } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:CreateDropCombo.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a dropdown Combo Combo combo = new Combo(shell, SWT.DROP_DOWN); combo.setItems(ITEMS);//from w ww . j av a 2 s. co m shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }