List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:Snippet102.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Tree tree = new Tree(shell, SWT.BORDER | SWT.MULTI); tree.setSize(200, 200);//from w w w . ja v a 2s . co m for (int i = 0; i < 12; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Item " + i); } TreeItem item = new TreeItem(tree, SWT.NONE, 1); TreeItem[] items = tree.getItems(); int index = 0; while (index < items.length && items[index] != item) index++; item.setText("*** New Item " + index + " ***"); 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(); // 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.jav a 2s . c om*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FontDataConstruct.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) { Font font = new Font(shell.getDisplay(), new FontData("Helvetica", 18, SWT.NORMAL)); e.gc.setFont(font);// www. j a v a2 s. c o m e.gc.drawText("My Text", 0, 0); font.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:TabItemWithToolTipImage.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER); for (int i = 0; i < 6; i++) { TabItem item = new TabItem(tabFolder, SWT.NONE); item.setText("TabItem " + i); item.setToolTipText("This is my tab" + i); item.setImage(new Image(display, "yourFile.gif")); Button button = new Button(tabFolder, SWT.PUSH); button.setText("Page " + i); item.setControl(button);/* ww w.j a v a2 s. com*/ } tabFolder.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ToolItemDropDownMenu.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.DROP_DOWN); item.setText("One"); DropdownSelectionListener listenerOne = new DropdownSelectionListener(item); listenerOne.add("Option One for One"); listenerOne.add("Option Two for One"); listenerOne.add("Option Three for One"); item.addSelectionListener(listenerOne); toolBar.pack();//from www .j a v a2 s .c o m shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FormLayoutFormAttachmentSetButton.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); FormLayout layout = new FormLayout(); layout.marginHeight = 5;//from w w w . j av a2 s .c om layout.marginWidth = 10; shell.setLayout(layout); Button one = new Button(shell, SWT.PUSH); one.setText("One"); FormData data = new FormData(); data.top = new FormAttachment(0, 5); data.left = new FormAttachment(0, 5); data.bottom = new FormAttachment(50, -5); data.right = new FormAttachment(50, -5); one.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet368.java
public static void main(String[] args) throws Exception { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 368"); shell.setLayout(new FillLayout()); shell.setText("Customize line spacing provider"); StyledText text = new StyledText(shell, SWT.BORDER | SWT.V_SCROLL); text.setText("a\nb\nc\nd"); text.setLineSpacingProvider(lineIndex -> { if (lineIndex == 0) { return 10; } else if (lineIndex == 1) { return 30; }/*from w w w . j av a 2s . co m*/ return null; }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:RowLayoutFill.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.fill = true; // Overriding default values. shell.setLayout(rowLayout);/*from w ww . ja v a 2 s . com*/ Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet101.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 101"); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); Rectangle clientArea = shell.getClientArea(); table.setBounds(clientArea.x, clientArea.y, 200, 200); for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); }//from ww w .j a va 2s . c o m TableItem item = new TableItem(table, SWT.NONE, 1); item.setText("*** New Item " + table.indexOf(item) + " ***"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MouseListenerUsing.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); shell.addMouseListener(new MouseListener() { public void mouseDoubleClick(MouseEvent arg0) { System.out.println("mouseDoubleClick"); }/*from w w w . ja v a2 s .c o m*/ public void mouseDown(MouseEvent arg0) { System.out.println("mouseDown"); } public void mouseUp(MouseEvent arg0) { System.out.println("mouseUp"); } }); // Display the window shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }