List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:EventListenerGeneral.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.SHADOW_IN | SWT.CENTER); shell.setLayout(new GridLayout()); Listener listener = new MouseEnterExitListener(); label.setText("Point your cursor here ..."); label.setBounds(30, 30, 200, 30);//w w w . j a v a 2 s . c o m label.addListener(SWT.MouseEnter, listener); label.addListener(SWT.MouseExit, listener); shell.setSize(260, 120); shell.open(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:FormLayoutFormData.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); FormLayout layout = new FormLayout(); layout.marginHeight = 5;/*from w w w . ja va 2 s .c o m*/ layout.marginWidth = 10; shell.setLayout(layout); Button button = new Button(shell, SWT.PUSH); button.setText("Button"); FormData data = new FormData(); data.height = 50; data.width = 50; button.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:SettingItemsAddItemAtOnce.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);// w w w. j av a 2s .c om shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:MenuActionListenerShow.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Listener showListener = new Listener() { public void handleEvent(Event event) { Menu menu = (Menu) event.widget; MenuItem item = menu.getParentItem(); if (item != null) { System.out.println(item.getText()); }/* w ww . j av a 2 s . c o m*/ } }; Menu menuBar = new Menu(shell, SWT.BAR); shell.setMenuBar(menuBar); MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE); fileItem.setText("File"); MenuItem editItem = new MenuItem(menuBar, SWT.CASCADE); editItem.setText("Edit"); Menu fileMenu = new Menu(shell, SWT.DROP_DOWN); fileMenu.addListener(SWT.Show, showListener); fileItem.setMenu(fileMenu); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GridLayoutFillBoth.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 3;/*from ww w .j ava 2 s .co m*/ layout.makeColumnsEqualWidth = true; shell.setLayout(layout); // Create the big button in the upper left GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = 200; Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.setLayoutData(data); // Create a composite to hold the three buttons in the upper right Composite composite = new Composite(shell, SWT.NONE); // Create button "two" data = new GridData(GridData.FILL_BOTH); Button two = new Button(composite, SWT.PUSH); two.setText("two"); two.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ControlTabTransversing.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Text text1 = new Text(shell, SWT.SINGLE | SWT.BORDER); text1.setText("Can't Traverse"); text1.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: { e.doit = false;//from w w w. ja v a2 s. c o m } } } }); Text text2 = new Text(shell, SWT.SINGLE | SWT.BORDER); text2.setText("Can Traverse"); 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 d = new Display(); final Shell s = new Shell(d); s.setSize(250, 200);//from w w w . j a v a 2 s . c om s.setText("A MouseListener Example"); final Button b = new Button(s, SWT.PUSH); b.setText("Push Me"); b.setBounds(20, 50, 55, 25); s.open(); b.addMouseMoveListener(new MouseMoveListener() { public void mouseMove(MouseEvent e) { System.out.println(e.x); } }); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:ComboSelect.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); String[] ITEMS = { "A", "B", "C", "D" }; final Combo combo = new Combo(shell, SWT.DROP_DOWN); combo.setItems(ITEMS);//from www . java 2 s . c o m combo.select(2); combo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { System.out.println(combo.getText()); } public void widgetDefaultSelected(SelectionEvent e) { System.out.println(combo.getText()); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GridLayoutComplex.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 3;//from w w w . ja va2 s. com layout.makeColumnsEqualWidth = true; shell.setLayout(layout); // Create the big button in the upper left GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = 200; Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.setLayoutData(data); // Create a composite to hold the three buttons in the upper right Composite composite = new Composite(shell, SWT.NONE); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; composite.setLayoutData(data); layout = new GridLayout(); layout.numColumns = 1; layout.marginHeight = 15; composite.setLayout(layout); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ListItemSelection.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a single-selection list List single = new List(shell, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); // Add the items, one by one for (int i = 0, n = ITEMS.length; i < n; i++) { single.add(ITEMS[i]);/*from w ww.j a v a 2 s .c o m*/ } // Select the third item single.select(2); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }