List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:MainClass.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); PrintDialog dlg = new PrintDialog(shell); dlg.setScope(PrinterData.SELECTION); PrinterData printerData = dlg.open(); if (printerData != null) { Printer printer = new Printer(printerData); System.out.println(printer.getClientArea()); printer.dispose();/*from ww w .ja v a 2 s . c om*/ } while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ReplaceStyleRanges.java
License:asdf
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("asdfasdfasdfasdf12345678910234567890"); StyleRange[] ranges = new StyleRange[2]; ranges[0] = new StyleRange(0, 3, display.getSystemColor(SWT.COLOR_GREEN), null); ranges[1] = new StyleRange(3, 6, display.getSystemColor(SWT.COLOR_BLUE), null); styledText.setStyleRanges(ranges);//from w ww. ja v a 2s.c o m styledText.replaceStyleRanges(5, 9, ranges); styledText.setBounds(10, 10, 500, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:MessageBoxWorkingIconAbortRetryIgnoreButton.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); int style = SWT.ICON_WORKING | SWT.ABORT | SWT.RETRY | SWT.IGNORE; MessageBox messageBox = new MessageBox(shell, style); messageBox.setMessage("Message"); int rc = messageBox.open(); switch (rc) { case SWT.OK:/*from w w w . j a v a2s . c o m*/ System.out.println("SWT.OK"); break; case SWT.CANCEL: System.out.println("SWT.CANCEL"); break; case SWT.YES: System.out.println("SWT.YES"); break; case SWT.NO: System.out.println("SWT.NO"); break; case SWT.RETRY: System.out.println("SWT.RETRY"); break; case SWT.ABORT: System.out.println("SWT.ABORT"); break; case SWT.IGNORE: System.out.println("SWT.IGNORE"); break; } display.dispose(); }
From source file:MouseEventDownUpMove.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); Listener listener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.MouseDown: System.out.println("down:" + event); break; case SWT.MouseMove: System.out.println("move:" + event); break; case SWT.MouseUp: System.out.println("Up:" + event); break; }/*from w ww . j av a 2s . c om*/ } }; shell.addListener(SWT.MouseDown, listener); shell.addListener(SWT.MouseUp, listener); shell.addListener(SWT.MouseMove, listener); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:LayoutTerm.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); System.out.println("Bounds: " + shell.getBounds()); System.out.println("Client area: " + shell.getClientArea()); shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); RowLayout rowLayout = new RowLayout(); shell.setLayout(rowLayout);/* w w w . ja v a 2 s. c o m*/ Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button2"); Button button3 = new Button(shell, SWT.PUSH); button3.setText("button33333333333333333333333333333333333333"); shell.pack(); shell.open(); System.out.println("button1: " + button1.getBounds()); System.out.println("button2: " + button2.getBounds()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ToolItemRadioGroups.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); ToolBar toolBar = new ToolBar(shell, SWT.BORDER | SWT.VERTICAL); ToolItem item = new ToolItem(toolBar, SWT.RADIO); item.setText("One"); item = new ToolItem(toolBar, SWT.RADIO); item.setText("Two"); item = new ToolItem(toolBar, SWT.RADIO); item.setText("Three"); new ToolItem(toolBar, SWT.SEPARATOR); // Signals end of group item = new ToolItem(toolBar, SWT.RADIO); item.setText("One"); item = new ToolItem(toolBar, SWT.RADIO); item.setText("Two"); item = new ToolItem(toolBar, SWT.RADIO); item.setText("Three"); toolBar.pack();//from w w w .java 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.setText("Sash One"); shell.setLayout(new FillLayout()); new Text(shell, SWT.BORDER); new Sash(shell, SWT.VERTICAL); new Text(shell, SWT.BORDER); shell.pack();//from w w w. ja v a2 s . com 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(); // Create the main window Shell shell = new Shell(display); shell.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent event) { // Get the event source (the shell) Shell shell = (Shell) event.getSource(); Rectangle rect = shell.getClientArea(); System.out.println(rect); }//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:SystemIconImage.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Label label = new Label(shell, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_ERROR)); label = new Label(shell, SWT.NONE); label.setText("SWT.ICON_ERROR"); label = new Label(shell, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_INFORMATION)); label = new Label(shell, SWT.NONE); label.setText("SWT.ICON_INFORMATION"); label = new Label(shell, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_WARNING)); label = new Label(shell, SWT.NONE); label.setText("SWT.ICON_WARNING"); label = new Label(shell, SWT.NONE); label.setImage(display.getSystemImage(SWT.ICON_QUESTION)); label = new Label(shell, SWT.NONE); label.setText("SWT.ICON_QUESTION"); shell.setSize(400, 350);/* w w w . ja v a2 s. co 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 d = new Display(); Shell s = new Shell(d); s.setSize(250, 250);/*from ww w . j a v a 2 s . c o m*/ s.setText("A RowLayout Example"); s.setLayout(new RowLayout()); final Text t = new Text(s, SWT.SINGLE | SWT.BORDER); final Button b = new Button(s, SWT.BORDER); final Button b1 = new Button(s, SWT.BORDER); b.setText("OK"); b1.setText("Cancel"); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }