List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:StyledTextVerifyListenerBackspaceDelete.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 w w w . j a va 2s .c o m // Allow backspace and delete if (event.character == '\u0008' || event.character == '\u007F') { event.doit = true; } } }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FormLayoutAttachControl.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); FormData formData = new FormData(); formData.left = new FormAttachment(50); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); button1.setLayoutData(formData);//from w w w . jav a 2 s . c o m shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:TextLink.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Text text0 = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); final Text text1 = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); text0.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent event) { text1.setTopIndex(text0.getTopIndex()); text1.setSelection(event.start, event.end); text1.insert(event.text);/*from w ww .j a v a 2s .c o m*/ } }); shell.setBounds(10, 10, 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) { Display d = new Display(); Shell s = new Shell(d); s.setSize(250, 250);/*ww w.j a v a 2 s.c o m*/ s.setText("A List Example"); final List l = new List(s, SWT.MULTI | SWT.BORDER); l.setBounds(50, 50, 75, 75); l.add("Item One"); l.add("Item Two"); l.add("Item Three"); l.add("Item Four"); l.add("Item Five"); final Button b1 = new Button(s, SWT.PUSH | SWT.BORDER); b1.setBounds(150, 150, 50, 25); b1.setText("Click Me"); b1.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String selected[] = l.getSelection(); for (int i = 0; i < selected.length; i++) { System.out.println(selected[i]); } } }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:CompositePaintListener.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL); final Composite composite = new Composite(shell, SWT.BORDER); composite.setSize(700, 600);// ww w . jav a 2 s. c o m final Color red = display.getSystemColor(SWT.COLOR_RED); composite.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.setBackground(red); e.gc.fillOval(5, 5, 690, 590); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ComboReadOnlyCreate.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a read-only Combo Combo readOnly = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY); readOnly.setItems(ITEMS);/*from www . j av a 2s. c om*/ shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ButtonSelectionListener.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 SelectionAdapter() { public void widgetSelected(SelectionEvent event) { System.out.println("selection event"); }/* ww w. j a va2 s .c om*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
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 ww . jav a 2 s . com*/ shell.setLayout(new FillLayout()); ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite child = new Composite(sc, SWT.NONE); child.setLayout(new FillLayout()); new Button(child, SWT.PUSH).setText("One"); new Button(child, SWT.PUSH).setText("Two"); sc.setContent(child); sc.setMinSize(300, 300); sc.setExpandHorizontal(true); sc.setExpandVertical(true); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
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[] { "Press enter to select", "B-1", "C-1" }); combo.addSelectionListener(new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { System.out.println("Combo"); }/*from ww w .j a v a 2s . c om*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:SelectRangeList.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a multiple-selection list List multi = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); // Add the items all at once multi.setItems(ITEMS);/* ww w . j a va2 s . co m*/ // Select a range multi.select(0, 2); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }