Example usage for org.eclipse.swt.widgets Button Button

List of usage examples for org.eclipse.swt.widgets Button Button

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Button Button.

Prototype


public Button(Composite parent, int style) 

Source Link

Document

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Usage

From source file:NoLayoutSimple.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Button button = new Button(shell, SWT.PUSH);
    button.setText("No layout");
    button.setBounds(5, 5, 50, 150);/*from w w w  . ja  va2 s .  c om*/

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

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);//  w  w w .  j ava2s  . c o  m

    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:PushButtonExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(3, true));

    // Create three push buttons
    new Button(shell, SWT.PUSH).setText("Push 1");
    new Button(shell, SWT.PUSH).setText("Push 2");
    new Button(shell, SWT.PUSH).setText("Push 3");

    shell.pack();//  w w w  .j  a v a2s.c  om
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:ArrowButtonExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(3, true));

    // Create three arrow buttons
    new Button(shell, SWT.ARROW);
    new Button(shell, SWT.ARROW | SWT.LEFT);
    new Button(shell, SWT.ARROW | SWT.DOWN);

    shell.pack();//from w ww.  j a  v a 2 s .c o  m
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:CheckBoxButtonExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(3, true));

    // Create three checkboxes
    new Button(shell, SWT.CHECK).setText("Checkbox 1");
    new Button(shell, SWT.CHECK).setText("Checkbox 2");
    new Button(shell, SWT.CHECK).setText("Checkbox 3");

    shell.pack();/*w  ww.j a  v a 2s.c o m*/
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:RadioButtonExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(3, true));

    // Create three radio buttons
    new Button(shell, SWT.RADIO).setText("Radio 1");
    new Button(shell, SWT.RADIO).setText("Radio 2");
    new Button(shell, SWT.RADIO).setText("Radio 3");

    shell.pack();/*from   ww w.j  a va 2 s . c  o  m*/
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:ToggleButtonExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(3, true));

    // Create three toggle buttons
    new Button(shell, SWT.TOGGLE).setText("Toggle 1");
    new Button(shell, SWT.TOGGLE).setText("Toggle 2");
    new Button(shell, SWT.TOGGLE).setText("Toggle 3");

    shell.pack();/*from  w  ww.  ja va  2 s  .  co  m*/
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:WidgetBoundsSetting.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setBounds(10, 10, 200, 200);/*w  ww  .j  av  a 2s .c  o m*/

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("&Typical button");
    button1.setBounds(10, 10, 180, 30);
    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("&Overidden button");
    button2.setBounds(10, 50, 180, 30);

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:FillLayoutVERTICAL.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout(SWT.VERTICAL));
    new Button(shell, SWT.PUSH).setText("one");
    new Button(shell, SWT.PUSH).setText("two");
    new Button(shell, SWT.PUSH).setText("three");
    shell.open();//  w ww.j  a  v  a  2s. co  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:FillLayoutHorizontal.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout(SWT.HORIZONTAL));
    new Button(shell, SWT.PUSH).setText("one");
    new Button(shell, SWT.PUSH).setText("two");
    new Button(shell, SWT.PUSH).setText("three");
    shell.open();//www.j a v  a  2 s .c  o m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}