List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:MouseTrackListenerUsing.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); shell.addMouseTrackListener(new MouseTrackListener() { public void mouseEnter(MouseEvent arg0) { System.out.println("mouseEnter"); }/*from w w w . j ava2 s . com*/ public void mouseExit(MouseEvent arg0) { System.out.println("mouseExit"); } public void mouseHover(MouseEvent arg0) { System.out.println("mouseHover"); } }); // Display the window shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet248.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 248"); shell.setLayout(new FillLayout()); shell.addListener(SWT.Traverse, event -> { switch (event.detail) { case SWT.TRAVERSE_ESCAPE: shell.close();/*from ww w .j a v a2s. co m*/ event.detail = SWT.TRAVERSE_NONE; event.doit = false; break; } }); Button button = new Button(shell, SWT.PUSH); button.setText("A Button (that doesn't process Escape)"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:EmbedSwingAWTSWT.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("SWT and Swing/AWT Example"); Composite treeComp = new Composite(shell, SWT.EMBEDDED); treeComp.setBounds(5, 5, 300, 300);/*from ww w . jav a 2s. co m*/ java.awt.Frame fileTableFrame = SWT_AWT.new_Frame(treeComp); java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout()); fileTableFrame.add(panel); JTree fileTable = new JTree(); fileTable.setDoubleBuffered(true); JScrollPane scrollPane = new JScrollPane(fileTable); panel.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:StyledTextStatistics.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"); System.out.println("Caret Offset: " + styledText.getCaretOffset()); System.out.println("Total Lines of Text: " + styledText.getLineCount()); System.out.println("Total Characters: " + styledText.getCharCount()); System.out.println("Current Line: " + (styledText.getLineAtOffset(styledText.getCaretOffset()) + 1)); styledText.setBounds(10, 10, 100, 100); shell.open();/*from www. jav a2 s . c o m*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet183.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Link link = new Link(shell, SWT.NONE); String text = "The SWT component is designed to provide <a>efficient</a>, <a>portable</a> <a href=\"native\">access to the user-interface facilities of the operating systems</a> on which it is implemented."; link.setText(text);/* w w w. jav a2 s.c o m*/ link.setSize(400, 400); 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:MainClass.java
public static void main(String[] a) { Display d = new Display(); Shell s = new Shell(d); s.setText("A Tabbed Shell Example"); final CoolBar bar = new CoolBar(s, SWT.BORDER); bar.setSize(280, 70);/*from w w w .j a v a2s .c om*/ bar.setLocation(0, 0); // final Image openIcon = new Image(d, "c:\\icons\\open.jpg"); final CoolItem openCoolItem = new CoolItem(bar, SWT.NONE); final Button openBtn = new Button(bar, SWT.PUSH); // openBtn.setImage(openIcon); openBtn.pack(); Point size = openBtn.getSize(); openCoolItem.setControl(openBtn); openCoolItem.setSize(openCoolItem.computeSize(size.x, size.y)); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet127.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 127"); shell.setLayout(new RowLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("Can't Traverse"); button1.addTraverseListener(e -> { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: { e.doit = false;/*w w w .j av a 2s . com*/ } } }); Button button2 = new Button(shell, SWT.PUSH); button2.setText("Can Traverse"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:StyledTextThrowEAway.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) { // If the text contains E or e, throw it all away if (event.text.indexOf('e') > -1 || event.text.indexOf('E') > -1) { event.text = ""; }//from w w w .jav a2 s .com } }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ComboGetText.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 ww w .java 2 s .c o m*/ 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:ScrollCompisiteHoriVertical.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SashForm Test"); shell.setLayout(new FillLayout()); // Create the ScrolledComposite to scroll horizontally and vertically ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite child = new Composite(sc, SWT.NONE); child.setLayout(new FillLayout()); new Button(child, SWT.PUSH).setText("One"); new Button(child, SWT.PUSH).setText("Two"); child.setSize(400, 400);//www . j a va 2s. c o m sc.setContent(child); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }