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

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

    shell.setLayout(new FormLayout());

    FormData formData = new FormData();
    formData.left = new FormAttachment(50);

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");
    button1.setLayoutData(formData);//from  w  w  w.j a v a 2  s . c  o m

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

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

From source file:TabFolderTabItem.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);
        Button button = new Button(tabFolder, SWT.PUSH);
        button.setText("Page " + i);
        item.setControl(button);/*  w w  w . j  a v  a 2  s. c o  m*/
    }
    tabFolder.pack();
    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) {
    Display d = new Display();
    final Shell s = new Shell(d);

    s.setSize(250, 200);//from w  ww.  ja  v  a2  s  . c om
    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();

}

From source file:GenericEventUntyped.java

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

    Button button = new Button(shell, SWT.NONE);
    button.setText("Click and check the console");
    button.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent arg0) {
            System.out.println("widgetSelected");
        }/*from  w w w . j a va 2 s  .  c o  m*/

        public void widgetDefaultSelected(SelectionEvent arg0) {
            System.out.println("widgetDefaultSelected");
        }
    });

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

From source file:ButtonWithEventListener.java

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

    Button button = new Button(shell, SWT.NONE);
    button.setText("Click and check the console");
    button.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            switch (e.type) {
            case SWT.Selection:
                System.out.println("Button pressed");
                break;
            }// www . j  a  v  a2s. co m
        }
    });

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

From source file:TabItemAddPushButton.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 | SWT.BOTTOM);
    for (int i = 0; i < 6; i++) {
        TabItem item = new TabItem(tabFolder, SWT.NONE);
        item.setText("TabItem " + i);
        Button button = new Button(tabFolder, SWT.PUSH);
        button.setText("Page " + i);
        item.setControl(button);/*from ww w  .  ja  v a  2 s .c  o  m*/
    }
    tabFolder.pack();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:FormLayoutFormDataWidthHeight.java

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

    shell.setLayout(new FormLayout());

    FormData formData = new FormData();
    formData.width = 100;//from   w  ww . j av  a  2  s  .c  o m
    formData.height = 200;

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

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

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

From source file:FormLayoutFormAttachmentSetButton.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    FormLayout layout = new FormLayout();
    layout.marginHeight = 5;//from w  ww .ja v a  2s.  c  om
    layout.marginWidth = 10;
    shell.setLayout(layout);

    Button one = new Button(shell, SWT.PUSH);
    one.setText("One");
    FormData data = new FormData();
    data.top = new FormAttachment(0, 5);
    data.left = new FormAttachment(0, 5);
    data.bottom = new FormAttachment(50, -5);
    data.right = new FormAttachment(50, -5);
    one.setLayoutData(data);

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

From source file:Snippet20.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    CoolBar bar = new CoolBar(shell, SWT.BORDER);
    for (int i = 0; i < 2; i++) {
        CoolItem item = new CoolItem(bar, SWT.NONE);
        Button button = new Button(bar, SWT.PUSH);
        button.setText("Button " + i);
        Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        item.setPreferredSize(item.computeSize(size.x, size.y));
        item.setControl(button);/*  ww w.java 2s.c  o  m*/
    }
    bar.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:ShellControlsGetting.java

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

    for (int i = 0; i < 20; i++) {
        Button button = new Button(shell, SWT.TOGGLE);
        button.setText("B" + i);
    }/*from  w ww  . ja v a  2  s .co  m*/
    Control[] children = shell.getChildren();
    for (int i = 0; i < children.length; i++) {
        Control child = children[i];
        System.out.println(child);
    }

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