List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:HorizontalSeparatorLabelExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(); shell.setLayout(new GridLayout(1, false)); // Create a horizontal separator Label separator = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR); separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); shell.open();/* w w w . j a v a 2s . c o m*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:LineCapsSetting.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { int x = 20, y = 20, w = 120, h = 60; GC gc = event.gc;// w w w.j av a 2 s .c om gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); gc.setLineWidth(10); int[] caps = { SWT.CAP_FLAT, SWT.CAP_ROUND, SWT.CAP_SQUARE }; for (int i = 0; i < caps.length; i++) { gc.setLineCap(caps[i]); gc.drawLine(x, y, x + w, y); y += 20; } } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TextKeyEventListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Text t = new Text(shell, SWT.SINGLE | SWT.BORDER); t.setBounds(10, 85, 100, 32);// w w w. j a va2 s. com Text t2 = new Text(shell, SWT.SINGLE | SWT.BORDER); t2.setBounds(10, 25, 100, 32); t2.addListener(SWT.KeyDown, new Listener() { public void handleEvent(Event e) { System.out.println("KEY"); } }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:LinkControlEventSelection.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Link link = new Link(shell, SWT.BORDER); link.setText("This a very simple <A href=\"htpp://www.java2s.com\">link</A> widget."); link.setSize(140, 40);//w w w. ja va2s . c o m link.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { System.out.println("Selection: " + event.text); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ShellControlsGetting.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); for (int i = 0; i < 20; i++) { Button button = new Button(shell, SWT.TOGGLE); button.setText("B" + i); }/* w w w .j a v a 2 s . c o m*/ Control[] children = shell.getChildren(); for (int i = 0; i < children.length; i++) { Control child = children[i]; System.out.println(child); } 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.setLayout(new GridLayout(1, false)); // Create a single line text field new Text(shell, SWT.BORDER); // Create a right-aligned single line text field new Text(shell, SWT.RIGHT | SWT.BORDER); // Create a password text field new Text(shell, SWT.PASSWORD | SWT.BORDER); // Create a read-only text field new Text(shell, SWT.READ_ONLY | SWT.BORDER).setText("Read Only"); // Create a multiple line text field Text t = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); t.setLayoutData(new GridData(GridData.FILL_BOTH)); shell.open();/* w w w . j a v a 2s . c o m*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:TextStrikeout.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("StyledText with underline and strike through"); shell.setLayout(new FillLayout()); StyledText text = new StyledText(shell, SWT.BORDER); text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ"); // make 0123456789 appear strikeout StyleRange style1 = new StyleRange(); style1.start = 0;/* w w w . j av a2s . c o m*/ style1.length = 10; style1.strikeout = true; text.setStyleRange(style1); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:RadioNoGroup.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); fileItem.setText("File"); fileItem.setMenu(fileMenu);/*from w w w . j a v a 2s.c om*/ MenuItem itema = new MenuItem(fileMenu, SWT.RADIO); itema.setText("Radio A"); MenuItem itemb = new MenuItem(fileMenu, SWT.RADIO); itemb.setText("Radio B"); MenuItem itemc = new MenuItem(fileMenu, SWT.RADIO); itemc.setText("Radio C"); shell.setMenuBar(menuBar); 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(); // Create the main window Shell shell = new Shell(display); Text fahrenheit = new Text(shell, SWT.BORDER); fahrenheit.setData("Type a temperature in Fahrenheit"); fahrenheit.setBounds(20, 20, 100, 20); fahrenheit.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { // Get the widget whose text was modified Text text = (Text) event.widget; System.out.println(text.getText()); }//from 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:TextUnderlined.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("StyledText with underline and strike through"); shell.setLayout(new FillLayout()); StyledText text = new StyledText(shell, SWT.BORDER); text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ"); // make 0123456789 appear underlined StyleRange style1 = new StyleRange(); style1.start = 0;//from w ww. j av a2 s . c o m style1.length = 10; style1.underline = true; text.setStyleRange(style1); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }