List of usage examples for org.eclipse.swt.widgets Display Display
public Display()
From source file:MainClass.java
public static void main(String[] a) { final Display d = new Display(); final Shell shell = new Shell(d); shell.setSize(250, 200);/*from ww w. j a va2 s. co m*/ shell.setLayout(new FillLayout()); Canvas drawingCanvas = new Canvas(shell, SWT.NONE); drawingCanvas.addPaintListener(new ArcExamplePaintListener()); drawingCanvas.redraw(); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:TableMultiCheckSelectionBorder.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 | SWT.CHECK); table.setLinesVisible(true);// w w w . ja va2s . c o m table.setHeaderVisible(true); String[] titles = { " ", "C", "!", "Description", "Resource", "In Folder", "Location" }; for (int i = 0; i < titles.length; i++) { TableColumn column = new TableColumn(table, SWT.NONE); 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, "dddddddddddddddddddd"); item.setText(4, "rrrrrrrrrrrrrrrrrrr"); item.setText(5, "some.folder"); item.setText(6, "line " + i + " in nowhere"); } 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:CanvasRepaint.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.drawRoundRectangle(10, 10, 200, 200, 30, 30); }/*w ww . ja v a2s . com*/ }); canvas.redraw(); 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);//from w ww .j ava 2 s . c om } tabFolder.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FocusEventInOut.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Text t = new Text(shell, SWT.SINGLE | SWT.BORDER); t.setBounds(10, 85, 100, 32);/* www .j av a2 s . c o m*/ Text t2 = new Text(shell, SWT.SINGLE | SWT.BORDER); t2.setBounds(10, 25, 100, 32); t2.addListener(SWT.FocusIn, new Listener() { public void handleEvent(Event e) { System.out.println("focus in"); } }); t2.addListener(SWT.FocusOut, new Listener() { public void handleEvent(Event e) { System.out.println("focus out"); } }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TableSelectionEvent.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); }/*w ww.j a v a2 s. c o m*/ table.setSize(100, 100); table.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { String string = event.detail == SWT.CHECK ? "Checked" : "Selected"; System.out.println(event.item + " " + string); } }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:DrawRoundRectangle.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.drawRoundRectangle(10, 10, 200, 200, 30, 30); }/*from ww w. ja v a 2 s . c o m*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutRowData.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); shell.setLayout(rowLayout);// w ww.ja v a 2 s. c o m 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"); list.setLayoutData(new RowData(100, 35)); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:StringPrint.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.open();//w ww. j av a2 s .co m PrinterData data = Printer.getDefaultPrinterData(); if (data == null) { System.out.println("Warning: No default printer."); } Printer printer = new Printer(data); if (printer.startJob("SWT Printing Snippet")) { Color black = printer.getSystemColor(SWT.COLOR_BLACK); GC gc = new GC(printer); if (printer.startPage()) { gc.setForeground(black); String testString = "Hello World!"; gc.drawString(testString, 200, 200); printer.endPage(); } gc.dispose(); printer.endJob(); } printer.dispose(); 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 Shell Composite Example"); GroupExample ge = new GroupExample(s, SWT.SHADOW_ETCHED_IN); ge.setLocation(20, 20);/*from www.j a va2s . c o m*/ s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }