List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:StyledTextArrowKeyVerifyKeyListener.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 ava 2 s. c o m // Allow arrow keys if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT) event.doit = true; } }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:UntypedEventListener.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) { System.out.println(e.button); switch (e.type) { case SWT.Selection: System.out.println("Button pressed"); break; }//w w w . j a v a2 s. c om } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:GroupWithoutGroupingRadioButtons.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // 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("A"); new Button(group2, SWT.RADIO).setText("B"); new Button(group2, SWT.RADIO).setText("C"); 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:ComboSimpleCreate.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a "simple" Combo Combo simple = new Combo(shell, SWT.SIMPLE); simple.setItems(ITEMS);// w w w. j a va 2 s . c om shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GCColorChange.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) { e.gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); e.gc.drawText("I'm in blue!", 20, 20); }/*from ww w . j av a 2s. 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.setText("A Shell Menu Example"); Menu m = new Menu(s, SWT.BAR); MenuItem file = new MenuItem(m, SWT.CASCADE); file.setText("File"); Menu filemenu = new Menu(s, SWT.DROP_DOWN); file.setMenu(filemenu);/*from w w w .ja v a 2 s . com*/ MenuItem openItem = new MenuItem(filemenu, SWT.PUSH); openItem.setText("&Open"); openItem.setAccelerator(SWT.CTRL + 'O'); openItem.addSelectionListener(new Open()); MenuItem exitItem = new MenuItem(filemenu, SWT.PUSH); exitItem.setText("Exit"); s.setMenuBar(m); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:CTabItemCloseButton.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);/* w w w . j a v a 2s . co m*/ } final CTabItem noCloseItem = new CTabItem(folder, SWT.NONE); noCloseItem.setText("No Close Button"); Text text2 = new Text(folder, SWT.MULTI); text2.setText("This tab does not have a close button"); noCloseItem.setControl(text2); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MenuItemWithImage.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); Menu menuBar = new Menu(shell, SWT.BAR); Menu fileMenu = new Menu(menuBar); MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE | SWT.NO_RADIO_GROUP); fileItem.setText("File"); fileItem.setMenu(fileMenu);// w w w . j a v a 2 s . co m Image yourImage = new Image(shell.getDisplay(), "yourFile.gif"); MenuItem itema = new MenuItem(fileMenu, SWT.NONE); itema.setText("Radio A"); itema.setImage(yourImage); MenuItem itemb = new MenuItem(fileMenu, SWT.NONE); itemb.setText("Radio B"); MenuItem itemc = new MenuItem(fileMenu, SWT.NONE); itemc.setText("Radio C"); shell.setMenuBar(menuBar); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:StyledTextLineBackgroundListener.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("\n1234\n124\n\1234\n12314\n\1241234\n"); styledText.addLineBackgroundListener(new LineBackgroundListener() { public void lineGetBackground(LineBackgroundEvent event) { if (event.lineText.indexOf("SWT") > -1) { event.lineBackground = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE); }//from www . ja v a2s .co m } }); styledText.setBounds(10, 10, 500, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:MenuCascade.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); Button bn = new Button(shell, SWT.FLAT); bn.setText("Right Click to see the popup menu"); Menu popupMenu = new Menu(bn); MenuItem newItem = new MenuItem(popupMenu, SWT.CASCADE); newItem.setText("New"); MenuItem refreshItem = new MenuItem(popupMenu, SWT.NONE); refreshItem.setText("Refresh"); MenuItem deleteItem = new MenuItem(popupMenu, SWT.NONE); deleteItem.setText("Delete"); Menu newMenu = new Menu(popupMenu); newItem.setMenu(newMenu);/*from ww w .j av a2 s. co m*/ MenuItem shortcutItem = new MenuItem(newMenu, SWT.NONE); shortcutItem.setText("Shortcut"); MenuItem iconItem = new MenuItem(newMenu, SWT.NONE); iconItem.setText("Icon"); bn.setMenu(popupMenu); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }