List of usage examples for org.eclipse.swt.widgets Display dispose
public void 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 ww w.j a va2s. 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(); }
From source file:FormLayoutAttachFourSidesControl.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); FormData formData = new FormData(); formData.left = new FormAttachment(50); formData.right = new FormAttachment(100); formData.top = new FormAttachment(50); formData.bottom = new FormAttachment(100); button1.setLayoutData(formData);/*from w ww . ja va2 s .c o m*/ shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:BrowserCloseWindowListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Browser browser = new Browser(shell, SWT.NONE); browser.setBounds(5, 5, 600, 600);/* w ww. j av a 2 s . c o m*/ browser.addCloseWindowListener(new CloseWindowListener() { public void close(WindowEvent event) { System.out.println("closing"); Browser browser = (Browser) event.widget; Shell shell = browser.getShell(); shell.close(); } }); browser.setUrl("http://java2s.com"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet198.java
public static void main(String[] args) { Display display = new Display(); FontData data = display.getSystemFont().getFontData()[0]; Font font = new Font(display, data.getName(), 96, SWT.BOLD | SWT.ITALIC); final Color green = display.getSystemColor(SWT.COLOR_GREEN); final Color blue = display.getSystemColor(SWT.COLOR_BLUE); final Path path; try {//from w w w . j a v a2 s .co m path = new Path(display); path.addString("SWT", 0, 0, font); } catch (SWTException e) { //Advanced Graphics not supported. //This new API requires the Cairo Vector engine on GTK and GDI+ on Windows. System.out.println(e.getMessage()); display.dispose(); return; } Shell shell = new Shell(display); shell.setText("Snippet 198"); shell.addListener(SWT.Paint, e -> { GC gc = e.gc; gc.setBackground(green); gc.setForeground(blue); gc.fillPath(path); gc.drawPath(path); }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } path.dispose(); font.dispose(); display.dispose(); }
From source file:StyledTextVerifyListenerEventInforation.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.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent event) { System.out.println(event.start); System.out.println(event.end); System.out.println(event.text); }/*from w w w. j a va 2 s .c o m*/ }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:AccessibleListenerAdding.java
License:asdf
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Label label = new Label(shell, SWT.NONE); label.setText("asdf"); Accessible accessible = label.getAccessible(); accessible.addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { super.getName(e); e.result = "Speak this instead of the text"; System.out.println("Accessible"); }//from w w w . jav a2s .com }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ScollCompositeControl.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // this button is always 400 x 400. Scrollbars appear if the window is // resized to be // too small to show part of the button ScrolledComposite c1 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Button b1 = new Button(c1, SWT.PUSH); b1.setText("fixed size button"); b1.setSize(400, 400);//from ww w .ja v a2s . c o m c1.setContent(b1); shell.setSize(600, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ComboTraverseListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Text text = new Text(shell, SWT.SINGLE | SWT.BORDER); text.setText("Press TAB"); Combo combo = new Combo(shell, SWT.NONE); combo.setItems(new String[] { "Press enter to select", "B-1", "C-1" }); combo.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { System.out.println("keyTraversed"); }/* ww w . j av a2 s . co m*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet213.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 213"); shell.setLayout(new FillLayout()); StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER); styledText.setText(text);/* ww w . ja v a 2s. co m*/ styledText.setLineIndent(0, 1, 50); styledText.setLineAlignment(2, 1, SWT.CENTER); styledText.setLineJustify(4, 1, true); styledText.setLineAlignment(6, 1, SWT.RIGHT); styledText.setLineJustify(6, 1, true); shell.setSize(300, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GCFromEvent.java
public static void main(String[] args) { Display display = new Display(); 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(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.drawFocus(5, 5, 200, 10); e.gc.drawText("You can draw text directly on a canvas", 60, 60); }/*ww w.java 2 s .c o m*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }