List of usage examples for org.eclipse.swt.widgets Display dispose
public void 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 om*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:PaintAWTInsideSWT.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.EMBEDDED); Frame frame = SWT_AWT.new_Frame(composite); Canvas canvas = new Canvas() { public void paint(Graphics g) { Dimension d = getSize(); g.drawLine(0, 0, d.width, d.height); }//from ww w . j a v a 2 s . co m }; frame.add(canvas); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TabFolderTabItem.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); Button button = new Button(tabFolder, SWT.PUSH); button.setText("Page " + i); item.setControl(button);//ww w . j a v a 2s . c om } tabFolder.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet284.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("URLTransfer"); shell.setLayout(new FillLayout()); final Label label1 = new Label(shell, SWT.BORDER); label1.setText("http://www.eclipse.org"); final Label label2 = new Label(shell, SWT.BORDER); setDragSource(label1);//from w w w. java 2 s . co m setDropTarget(label2); shell.setSize(600, 300); 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); }/*from w w w .j a v a2 s . co 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:FontLargerCreate.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Text text = new Text(shell, SWT.MULTI | SWT.BORDER); text.setBounds(10, 10, 150, 150);/*from w w w . j a va 2 s .c o m*/ Font initialFont = text.getFont(); FontData[] fontData = initialFont.getFontData(); for (int i = 0; i < fontData.length; i++) { fontData[i].setHeight(24); } Font newFont = new Font(display, fontData); text.setFont(newFont); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } newFont.dispose(); display.dispose(); }
From source file:GroupWithoutGroupingRadioButtons.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create the second Group Group group2 = new Group(shell, SWT.NO_RADIO_GROUP); group2.setText("Who's your favorite?"); group2.setLayout(new RowLayout(SWT.VERTICAL)); new Button(group2, SWT.RADIO).setText("A"); new Button(group2, SWT.RADIO).setText("B"); new Button(group2, SWT.RADIO).setText("C"); shell.open();/* w w w. ja v a2 s.c o m*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:DrawFocusRectangle.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); }// www. ja v a 2 s . c o m }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:CTabFolderAddCTabItem.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); CTabFolder folder = new CTabFolder(shell, SWT.BORDER); for (int i = 0; i < 4; i++) { CTabItem item = new CTabItem(folder, SWT.CLOSE); item.setText("Item " + i); Text text = new Text(folder, SWT.MULTI); text.setText("Content for Item " + i); item.setControl(text);//from w w w.j a va 2s .c om } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TableItemGetIndex.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200);/*w w w . ja v a2 s .co m*/ for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } TableItem item = new TableItem(table, SWT.NONE, 5); item.setText(" New Item "); System.out.println(table.indexOf(item)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }