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

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

Introduction

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

Prototype

public void setText(String text) 

Source Link

Document

Sets the receiver's text.

Usage

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 .ja  va  2 s  .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, 200);
    shell.open();

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

From source file:SashFromMaximizeControl.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("SashForm Test");
    // Fill the parent window with the buttons and sash
    shell.setLayout(new FillLayout());

    // Create the SashForm and the buttons
    SashForm sashForm = new SashForm(shell, SWT.VERTICAL);
    new Button(sashForm, SWT.PUSH).setText("Left");
    Button control = new Button(sashForm, SWT.PUSH);
    control.setText("Right");
    sashForm.setOrientation(SWT.HORIZONTAL);

    if (control == sashForm.getMaximizedControl()) {
        sashForm.setMaximizedControl(null);
    } else {/*  w w  w  . j av a  2 s .co  m*/
        sashForm.setMaximizedControl(control);
    }

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

}

From source file:EventSelection.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);
    shell.setLayout(new FillLayout());

    Button button = new Button(shell, SWT.RIGHT);

    button.setText("text on the button");

    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent arg0) {
            System.out.println("selected");
        }/*from   w w w  .j  a  v  a  2 s  .  c om*/

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });

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

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

    // this button has a minimum size of 400 x 400. If the window is resized to be big
    // enough to show more than 400 x 400, the button will grow in size. If the window
    // is made too small to show 400 x 400, scrollbars will appear.
    ScrolledComposite c2 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    Button b2 = new Button(c2, SWT.PUSH);
    b2.setText("expanding button");
    c2.setContent(b2);/* www  .  j  a v  a  2s  .co  m*/
    c2.setExpandHorizontal(true);
    c2.setExpandVertical(true);
    c2.setMinWidth(400);
    c2.setMinHeight(400);

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

From source file:PopupListUsing.java

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("PopupList Test");
    shell.setLayout(new RowLayout());

    // Create a button to launch the list
    Button button = new Button(shell, SWT.PUSH);
    button.setText("Push Me");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            PopupList list = new PopupList(shell);

            list.setItems(new String[] { "A", "B", "C" });

            String selected = list.open(shell.getBounds());
            System.out.println(selected);
        }/*  w ww. ja v  a2  s  . c o m*/
    });

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

}

From source file:MenuCascade.java

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

    Button bn = new Button(shell, SWT.FLAT);
    bn.setText("Right Click to see the popup menu");

    Menu popupMenu = new Menu(bn);
    MenuItem newItem = new MenuItem(popupMenu, SWT.CASCADE);
    newItem.setText("New");
    MenuItem refreshItem = new MenuItem(popupMenu, SWT.NONE);
    refreshItem.setText("Refresh");
    MenuItem deleteItem = new MenuItem(popupMenu, SWT.NONE);
    deleteItem.setText("Delete");

    Menu newMenu = new Menu(popupMenu);
    newItem.setMenu(newMenu);/*ww  w.j a  va  2  s  .  c o  m*/

    MenuItem shortcutItem = new MenuItem(newMenu, SWT.NONE);
    shortcutItem.setText("Shortcut");
    MenuItem iconItem = new MenuItem(newMenu, SWT.NONE);
    iconItem.setText("Icon");

    bn.setMenu(popupMenu);

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

From source file:GridLayoutFillBoth.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;/*from w ww. ja  va2 s  .  c  om*/
    layout.makeColumnsEqualWidth = true;
    shell.setLayout(layout);

    // Create the big button in the upper left
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 200;
    Button one = new Button(shell, SWT.PUSH);
    one.setText("one");
    one.setLayoutData(data);

    // Create a composite to hold the three buttons in the upper right
    Composite composite = new Composite(shell, SWT.NONE);

    // Create button "two"
    data = new GridData(GridData.FILL_BOTH);
    Button two = new Button(composite, SWT.PUSH);
    two.setText("two");
    two.setLayoutData(data);

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

From source file:MarginSpaceProperties.java

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);

    FillLayout fillLayout = new FillLayout(SWT.HORIZONTAL);

    // Width of horizontal margins placed along the left and right edges    
    fillLayout.marginWidth = 5;//w  w  w  .j  a  v a2 s.  c  o m
    // Height of vertical margins placed along the top and bottom edges
    fillLayout.marginHeight = 5;

    shell.setLayout(fillLayout);

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("button number 2");

    Button button3 = new Button(shell, SWT.PUSH);
    button3.setText("3");

    shell.setSize(450, 100);
    shell.open();

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

From source file:GridLayoutHORIZONTALALIGNCENTER.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;//  w w  w.j  ava2 s  .c  o  m
    layout.makeColumnsEqualWidth = true;
    shell.setLayout(layout);

    // Create the big button in the upper left
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 200;
    Button one = new Button(shell, SWT.PUSH);
    one.setText("one");
    one.setLayoutData(data);

    // Create a composite to hold the three buttons in the upper right
    Composite composite = new Composite(shell, SWT.NONE);

    // Create button "three"
    data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    Button three = new Button(composite, SWT.PUSH);
    three.setText("three");
    three.setLayoutData(data);

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

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);/* www .j ava  2 s  . co  m*/

    shell.setLayout(new RowLayout());

    Button button = new Button(shell, SWT.PUSH);
    button.setText("Push Me");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            PopupList list = new PopupList(shell);
            String[] OPTIONS = { "A", "B", "C" };

            list.setItems(OPTIONS);

            String selected = list.open(shell.getBounds());

            System.out.println(selected);
        }
    });

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