List of usage examples for org.eclipse.swt.widgets Button getSize
public Point getSize()
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 va2 s. c o m 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:Snippet126.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setLinesVisible(true);//from w w w.j a v a2s.c o m for (int i = 0; i < 3; i++) { TableColumn column = new TableColumn(table, SWT.NONE); column.setWidth(100); } for (int i = 0; i < 12; i++) { new TableItem(table, SWT.NONE); } TableItem[] items = table.getItems(); for (int i = 0; i < items.length; i++) { TableEditor editor = new TableEditor(table); CCombo combo = new CCombo(table, SWT.NONE); editor.grabHorizontal = true; editor.setEditor(combo, items[i], 0); editor = new TableEditor(table); Text text = new Text(table, SWT.NONE); editor.grabHorizontal = true; editor.setEditor(text, items[i], 1); editor = new TableEditor(table); Button button = new Button(table, SWT.CHECK); button.pack(); editor.minimumWidth = button.getSize().x; editor.horizontalAlignment = SWT.LEFT; editor.setEditor(button, items[i], 2); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet126.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 126"); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setLinesVisible(true);// www . j a va 2 s .co m for (int i = 0; i < 3; i++) { TableColumn column = new TableColumn(table, SWT.NONE); column.setWidth(100); } for (int i = 0; i < 12; i++) { new TableItem(table, SWT.NONE); } TableItem[] items = table.getItems(); for (int i = 0; i < items.length; i++) { TableEditor editor = new TableEditor(table); CCombo combo = new CCombo(table, SWT.NONE); combo.setText("CCombo"); combo.add("item 1"); combo.add("item 2"); editor.grabHorizontal = true; editor.setEditor(combo, items[i], 0); editor = new TableEditor(table); Text text = new Text(table, SWT.NONE); text.setText("Text"); editor.grabHorizontal = true; editor.setEditor(text, items[i], 1); editor = new TableEditor(table); Button button = new Button(table, SWT.CHECK); button.pack(); editor.minimumWidth = button.getSize().x; editor.horizontalAlignment = SWT.LEFT; editor.setEditor(button, items[i], 2); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TableCellEditorComboTextButton.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setLinesVisible(true);//from w ww .j a va2 s . co m for (int i = 0; i < 3; i++) { TableColumn column = new TableColumn(table, SWT.NONE); column.setWidth(100); } for (int i = 0; i < 12; i++) { new TableItem(table, SWT.NONE); } TableItem[] items = table.getItems(); for (int i = 0; i < items.length; i++) { TableEditor editor = new TableEditor(table); CCombo combo = new CCombo(table, SWT.NONE); combo.setText("CCombo"); combo.add("item 1"); combo.add("item 2"); editor.grabHorizontal = true; editor.setEditor(combo, items[i], 0); editor = new TableEditor(table); Text text = new Text(table, SWT.NONE); text.setText("Text"); editor.grabHorizontal = true; editor.setEditor(text, items[i], 1); editor = new TableEditor(table); Button button = new Button(table, SWT.CHECK); button.pack(); editor.minimumWidth = button.getSize().x; editor.horizontalAlignment = SWT.LEFT; editor.setEditor(button, items[i], 2); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ControlSizeLocation.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Button button = new Button(shell, SWT.PUSH); shell.setSize(260, 120);//from ww w . j a v a 2 s.c om shell.open(); System.out.println("------------------------------"); System.out.println("getBounds: " + button.getBounds()); System.out.println("getLocation: " + button.getLocation()); System.out.println("getSize: " + button.getSize()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:ControlBounds.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Button button = new Button(shell, SWT.PUSH); button.setBounds(20, 20, 200, 20);//from ww w. j av a2 s .c om shell.setSize(260, 120); shell.open(); System.out.println("------------------------------"); System.out.println("getBounds: " + button.getBounds()); System.out.println("getLocation: " + button.getLocation()); System.out.println("getSize: " + button.getSize()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:org.eclipse.swt.snippets.Snippet68.java
public static void main(String[] args) { final Display display = new Display(); final Color red = display.getSystemColor(SWT.COLOR_RED); final Color blue = display.getSystemColor(SWT.COLOR_BLUE); Shell shell = new Shell(display); shell.setText("Snippet 68"); shell.setLayout(new RowLayout()); Button button = new Button(shell, SWT.PUSH); button.setText("Stop Timer"); final Label label = new Label(shell, SWT.BORDER); label.setBackground(red);/* w ww. j av a 2s. com*/ final int time = 500; final Runnable timer = new Runnable() { @Override public void run() { if (label.isDisposed()) return; Color color = label.getBackground().equals(red) ? blue : red; label.setBackground(color); display.timerExec(time, this); } }; display.timerExec(time, timer); button.addListener(SWT.Selection, event -> display.timerExec(-1, timer)); button.pack(); label.setLayoutData(new RowData(button.getSize())); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TimeStopWhenButtonPressing.java
public static void main(String[] args) { final Display display = new Display(); final Color red = display.getSystemColor(SWT.COLOR_RED); final Color blue = display.getSystemColor(SWT.COLOR_BLUE); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Button button = new Button(shell, SWT.PUSH); button.setText("Stop Timer"); final Label label = new Label(shell, SWT.BORDER); label.setBackground(red);/*from w ww. j ava 2 s. c o m*/ final int time = 500; final Runnable timer = new Runnable() { public void run() { if (label.isDisposed()) return; Color color = label.getBackground().equals(red) ? blue : red; label.setBackground(color); display.timerExec(time, this); } }; display.timerExec(time, timer); button.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { display.timerExec(-1, timer); } }); button.pack(); label.setLayoutData(new RowData(button.getSize())); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }