List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
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 = ""; }// www.j av a2s. c om } }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ControlListenerUsing.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); shell.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent event) { Shell shell = (Shell) event.getSource(); Rectangle rect = shell.getClientArea(); System.out.println(rect); }// w ww . j ava 2 s .c om }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:Snippet105.java
public static void main(String[] args) { Display display = new Display(); Program.launch("c:\\cygwin\\cygwin.bat"); display.dispose();//from w w w. ja v a2 s.c om }
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 w w w . j a v a2s . c o 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:TreeSingleSelection.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("TreeExample"); Tree tree = new Tree(shell, SWT.SINGLE | SWT.BORDER); // Turn off drawing to avoid flicker tree.setRedraw(false);/*ww w . ja va2 s. c o m*/ for (int i = 0; i < 5; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Root Item " + i); for (int j = 0; j < 3; j++) { TreeItem child = new TreeItem(item, SWT.NONE); child.setText("Child Item " + i + " - " + j); for (int k = 0; k < 3; k++) { TreeItem grandChild = new TreeItem(child, SWT.NONE); grandChild.setText("Grandchild Item " + i + " - " + j + " - " + k); } } } tree.setRedraw(true); tree.setBounds(10, 10, 400, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GridLayout2x2.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*from w w w. java 2 s . co m*/ layout.makeColumnsEqualWidth = true; shell.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); Button two = new Button(shell, SWT.PUSH); two.setText("two"); two.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); Button three = new Button(shell, SWT.PUSH); three.setText("three"); three.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); Button four = new Button(shell, SWT.PUSH); four.setText("four"); four.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:BrowserLocationListener.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);/*from ww w. j a v a 2 s.c o m*/ browser.addLocationListener(new LocationListener() { public void changed(LocationEvent event) { if (event.top) System.out.println(event.location); } public void changing(LocationEvent event) { } }); browser.setUrl("http://java2s.com"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TableColumnAdding.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); table.setLinesVisible(true);/*ww w .j av a 2 s . co m*/ table.setHeaderVisible(true); String[] titles = { " ", "C", "!", "Description" }; for (int i = 0; i < titles.length; i++) { TableColumn column = new TableColumn(table, SWT.RIGHT); column.setText(titles[i]); } for (int i = 0; i < 10; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText(0, "x"); item.setText(1, "y"); item.setText(2, "!"); item.setText(3, "d"); } for (int i = 0; i < titles.length; i++) { table.getColumn(i).pack(); } table.setSize(table.computeSize(SWT.DEFAULT, 200)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:StyledTextModifyListener.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER); styledText.setText("12345"); styledText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { System.out.println("Character Count: " + styledText.getCharCount()); }//from w ww.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:GridLayoutMakeColumnWidth.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;/*from w ww . jav a 2 s . c om*/ gridLayout.makeColumnsEqualWidth = true; shell.setLayout(gridLayout); 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"); Button button3 = new Button(shell, SWT.PUSH); button3.setText("button #3"); shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }