List of usage examples for org.eclipse.swt.widgets Button Button
public Button(Composite parent, int style)
From source file:GridLayoutDefaultValues.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); GridLayout gridLayout = new GridLayout(); shell.setLayout(gridLayout);//from w w w. j a v a 2 s .c om 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, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FormLayoutAttachFourSidesControl.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); FormData formData = new FormData(); formData.left = new FormAttachment(50); formData.right = new FormAttachment(100); formData.top = new FormAttachment(50); formData.bottom = new FormAttachment(100); button1.setLayoutData(formData);//from w w w .j a v a 2s . com shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FormLayoutAnotherControl.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button2"); FormData formData = new FormData(); formData.left = new FormAttachment(button1); button2.setLayoutData(formData);//w w w .j av a 2s .com Button button3 = new Button(shell, SWT.PUSH); button3.setText("button3"); formData = new FormData(); formData.top = new FormAttachment(button2, 10); formData.left = new FormAttachment(button2, 0, SWT.LEFT); button3.setLayoutData(formData); shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FormLayoutLeftRight.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); FormData formData = new FormData(); formData.left = new FormAttachment(20); formData.top = new FormAttachment(20); button1.setLayoutData(formData);//from ww w.ja va 2s .c o m shell.pack(); shell.open(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:RowLayoutWrap.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.wrap = false;/* w w w. j av a 2 s . co m*/ shell.setLayout(rowLayout); 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, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FormLayoutAttachAnotherControl.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button2"); FormData formData = new FormData(); formData.left = new FormAttachment(button1); button2.setLayoutData(formData);//w w w .ja va2 s. com Button button3 = new Button(shell, SWT.PUSH); button3.setText("button3"); formData = new FormData(); formData.top = new FormAttachment(button2, 10); button3.setLayoutData(formData); shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutSpacing.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.spacing = 40;/*from w w w .ja v a2 s .com*/ shell.setLayout(rowLayout); 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:FormLayoutCenterAnotherControl.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button222222222222222222222"); FormData formData = new FormData(); formData.left = new FormAttachment(button1); button2.setLayoutData(formData);/*from w w w . j a v a 2s. c om*/ Button button3 = new Button(shell, SWT.PUSH); button3.setText("button3"); formData = new FormData(); formData.top = new FormAttachment(button2, 10); formData.left = new FormAttachment(button2, 0, SWT.CENTER); button3.setLayoutData(formData); shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutJustify.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.justify = true;//www . j av a 2s .c o m shell.setLayout(rowLayout); 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:MainClass.java
public static void main(String[] a) { Display d = new Display(); final Shell s = new Shell(d); s.setSize(250, 200);// w w w .j a va2s . co m s.setText("A MouseListener Example"); final Button b = new Button(s, SWT.PUSH); b.setText("Push Me"); b.setBounds(20, 50, 55, 25); s.open(); b.addMouseMoveListener(new MouseMoveListener() { public void mouseMove(MouseEvent e) { System.out.println(e.x); } }); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }