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

public Thread getTask(Button button) {
    final Button theButton = button;
    return new Thread() {
        public void run() {
            double pi = calculatePI(9999999);
            theButton.setText("PI = " + pi); // Update UI.
        }/*from   ww w  .jav a  2 s  .c  o  m*/
    };
}

From source file:MainClass.java

public void createContents(Shell shell, String location) {
    shell.setLayout(new FormLayout());

    Composite controls = new Composite(shell, SWT.NONE);
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    controls.setLayoutData(data);//  w  ww  .  ja  v  a  2 s .  co m

    Label status = new Label(shell, SWT.NONE);
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    status.setLayoutData(data);

    final Browser browser = new Browser(shell, SWT.BORDER);
    data = new FormData();
    data.top = new FormAttachment(controls);
    data.bottom = new FormAttachment(status);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    browser.setLayoutData(data);

    controls.setLayout(new GridLayout(7, false));

    Button button = new Button(controls, SWT.PUSH);
    button.setText("Back");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.back();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Forward");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.forward();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Refresh");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.refresh();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Stop");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.stop();
        }
    });

    final Text url = new Text(controls, SWT.BORDER);
    url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    url.setFocus();

    button = new Button(controls, SWT.PUSH);
    button.setText("Go");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.setUrl(url.getText());
        }
    });

    Label throbber = new Label(controls, SWT.NONE);
    throbber.setText(AT_REST);

    shell.setDefaultButton(button);

    browser.addCloseWindowListener(new AdvancedCloseWindowListener());
    browser.addLocationListener(new AdvancedLocationListener(url));
    browser.addProgressListener(new AdvancedProgressListener(throbber));
    browser.addStatusTextListener(new AdvancedStatusTextListener(status));

    if (location != null) {
        browser.setUrl(location);
    }
}

From source file:Sample.java

public Sample() {
    shell.setText("Book Entry Demo");

    GridLayout gridLayout = new GridLayout(4, false);
    gridLayout.verticalSpacing = 8;//from w w w . ja v  a  2  s.  c  o m

    shell.setLayout(gridLayout);

    // Title
    Label label = new Label(shell, SWT.NULL);
    label.setText("Title: ");

    Text title = new Text(shell, SWT.SINGLE | SWT.BORDER);
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 3;
    title.setLayoutData(gridData);

    // Author(s)
    label = new Label(shell, SWT.NULL);
    label.setText("Author(s): ");

    Text authors = new Text(shell, SWT.SINGLE | SWT.BORDER);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 3;
    authors.setLayoutData(gridData);

    // Cover
    label = new Label(shell, SWT.NULL);
    label.setText("Cover: ");

    gridData = new GridData();
    gridData.verticalSpan = 3;
    label.setLayoutData(gridData);

    CLabel cover = new CLabel(shell, SWT.NULL);

    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 1;
    gridData.verticalSpan = 3;
    gridData.heightHint = 100;
    gridData.widthHint = 100;

    cover.setLayoutData(gridData);

    // Details.
    label = new Label(shell, SWT.NULL);
    label.setText("Pages");

    Text pages = new Text(shell, SWT.SINGLE | SWT.BORDER);
    pages.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    label = new Label(shell, SWT.NULL);
    label.setText("Publisher");

    Text pubisher = new Text(shell, SWT.SINGLE | SWT.BORDER);
    pubisher.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    label = new Label(shell, SWT.NULL);
    label.setText("Rating");

    Combo rating = new Combo(shell, SWT.READ_ONLY);
    rating.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    rating.add("5");
    rating.add("4");
    rating.add("3");
    rating.add("2");
    rating.add("1");

    // Abstract.

    label = new Label(shell, SWT.NULL);
    label.setText("Abstract:");

    Text bookAbstract = new Text(shell, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    gridData.horizontalSpan = 3;
    gridData.grabExcessVerticalSpace = true;

    bookAbstract.setLayoutData(gridData);

    // Button.
    Button enter = new Button(shell, SWT.PUSH);
    enter.setText("Enter");

    gridData = new GridData();
    gridData.horizontalSpan = 4;
    gridData.horizontalAlignment = GridData.END;
    enter.setLayoutData(gridData);

    // Fill information.

    title.setText("Professional Java Interfaces with SWT/JFace");
    authors.setText("Jack Li Guojie");
    pages.setText("500pp");
    pubisher.setText("John Wiley & Sons");
    cover.setBackground(new Image(display, "java2s.gif"));
    bookAbstract.setText("This book provides a comprehensive guide for \n"
            + "you to create Java user interfaces with SWT/JFace. ");

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

protected void buildControls() {
    final Composite parent = this;
    FillLayout layout = new FillLayout();
    parent.setLayout(layout);/*w  ww.j a  v a  2  s  .c  o m*/

    Button dialogBtn = new Button(parent, SWT.PUSH);
    dialogBtn.setText("Wizard Dialog...");
    dialogBtn.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            WizardDialog dialog = new WizardDialog(parent.getShell(), new ProjectWizard());
            dialog.open();
        }

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

From source file:org.eclipse.swt.examples.paint.TextTool.java

/**
 * Handles a mouseDown event.//  ww  w. java2  s .co m
 *
 * @param event the mouse event detail information
 */
@Override
public void mouseDown(MouseEvent event) {
    if (event.button == 1) {
        // draw with left mouse button
        getPaintSurface().commitRubberbandSelection();
    } else {
        // set text with right mouse button
        getPaintSurface().clearRubberbandSelection();
        Shell shell = getPaintSurface().getShell();
        final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
        dialog.setText(PaintExample.getResourceString("tool.Text.dialog.title"));
        dialog.setLayout(new GridLayout());
        Label label = new Label(dialog, SWT.NONE);
        label.setText(PaintExample.getResourceString("tool.Text.dialog.message"));
        label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
        final Text field = new Text(dialog, SWT.SINGLE | SWT.BORDER);
        field.setText(drawText);
        field.selectAll();
        field.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        Composite buttons = new Composite(dialog, SWT.NONE);
        GridLayout layout = new GridLayout(2, true);
        layout.marginWidth = 0;
        buttons.setLayout(layout);
        buttons.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
        Button ok = new Button(buttons, SWT.PUSH);
        ok.setText(PaintExample.getResourceString("OK"));
        ok.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
        ok.addSelectionListener(widgetSelectedAdapter(e -> {
            drawText = field.getText();
            dialog.dispose();
        }));
        Button cancel = new Button(buttons, SWT.PUSH);
        cancel.setText(PaintExample.getResourceString("Cancel"));
        cancel.addSelectionListener(widgetSelectedAdapter(e -> dialog.dispose()));
        dialog.setDefaultButton(ok);
        dialog.pack();
        dialog.open();
        Display display = dialog.getDisplay();
        while (!shell.isDisposed() && !dialog.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
    }
}

From source file:org.jfree.experimental.chart.swt.editor.SWTChartEditor.java

/**
 * Creates a new editor./*from  w  w w. j a  v a  2  s  .co  m*/
 * 
 * @param shell2 the display.
 * @param chart2edit the chart to edit.
 */
public SWTChartEditor(Shell shell2, JFreeChart chart2edit) {

    this.shell = new Shell(Display.getDefault(), SWT.DIALOG_TRIM);
    this.shell.setSize(400, 500);
    this.chart = chart2edit;
    this.shell.setText(
            ResourceBundle.getBundle("org.jfree.chart.LocalizationBundle").getString("Chart_Properties"));
    GridLayout layout = new GridLayout(2, true);
    layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5;
    this.shell.setLayout(layout);
    Composite main = new Composite(this.shell, SWT.NONE);
    main.setLayout(new FillLayout());
    main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

    TabFolder tab = new TabFolder(main, SWT.BORDER);
    // build first tab
    TabItem item1 = new TabItem(tab, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Title") + " ");
    this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, this.chart.getTitle());
    item1.setControl(this.titleEditor);
    // build second tab
    TabItem item2 = new TabItem(tab, SWT.NONE);
    item2.setText(" " + localizationResources.getString("Plot") + " ");
    this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, this.chart.getPlot());
    item2.setControl(this.plotEditor);
    // build the third tab
    TabItem item3 = new TabItem(tab, SWT.NONE);
    item3.setText(" " + localizationResources.getString("Other") + " ");
    this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart);
    item3.setControl(this.otherEditor);

    // ok and cancel buttons
    Button ok = new Button(this.shell, SWT.PUSH | SWT.OK);
    ok.setText(" Ok ");
    ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    ok.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updateChart(SWTChartEditor.this.chart);
            SWTChartEditor.this.shell.dispose();
        }
    });
    Button cancel = new Button(this.shell, SWT.PUSH);
    cancel.setText(" Cancel ");
    cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    cancel.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            SWTChartEditor.this.shell.dispose();
        }
    });
}

From source file:com.rcp.wbw.demo.editor.SWTChartEditor.java

/**
 * Creates a new editor./*w w  w .j av a2  s . com*/
 * 
 * @param display
 *            the display.
 * @param chart2edit
 *            the chart to edit.
 */
public SWTChartEditor(Display display, JFreeChart chart2edit) {
    this.shell = new Shell(display, SWT.DIALOG_TRIM);
    this.shell.setSize(400, 500);
    this.chart = chart2edit;
    this.shell.setText(ResourceBundleWrapper.getBundle("org.jfree.chart.LocalizationBundle")
            .getString("Chart_Properties"));
    GridLayout layout = new GridLayout(2, true);
    layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5;
    this.shell.setLayout(layout);
    Composite main = new Composite(this.shell, SWT.NONE);
    main.setLayout(new FillLayout());
    main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

    TabFolder tab = new TabFolder(main, SWT.BORDER);
    // build first tab
    TabItem item1 = new TabItem(tab, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Title") + " ");
    this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, this.chart.getTitle());
    item1.setControl(this.titleEditor);
    // build second tab
    TabItem item2 = new TabItem(tab, SWT.NONE);
    item2.setText(" " + localizationResources.getString("Plot") + " ");
    this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, this.chart.getPlot());
    item2.setControl(this.plotEditor);
    // build the third tab
    TabItem item3 = new TabItem(tab, SWT.NONE);
    item3.setText(" " + localizationResources.getString("Other") + " ");
    this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart);
    item3.setControl(this.otherEditor);

    // ok and cancel buttons
    Button ok = new Button(this.shell, SWT.PUSH | SWT.OK);
    ok.setText(" Ok ");
    ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    ok.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updateChart(SWTChartEditor.this.chart);
            SWTChartEditor.this.shell.dispose();
        }
    });
    Button cancel = new Button(this.shell, SWT.PUSH);
    cancel.setText(" Cancel ");
    cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    cancel.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            SWTChartEditor.this.shell.dispose();
        }
    });
}

From source file:DialogExamples.java

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);

    composite.setLayout(new GridLayout());

    /* ------ MessageDialog ------------- */
    // openQuestion
    final Button buttonOpenMessage = new Button(composite, SWT.PUSH);
    buttonOpenMessage.setText("Demo: MessageDialog.openQuestion");
    buttonOpenMessage.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {

            boolean answer = MessageDialog.openQuestion(getShell(), "A Simple Question",
                    "Is SWT/JFace your favorite Java UI framework?");
            System.out.println("Your answer is " + (answer ? "YES" : "NO"));
        }//w w  w.j a  va  2s . c om
    });

    final Button buttonMessageDialog = new Button(composite, SWT.PUSH);
    buttonMessageDialog.setText("Demo: new MessageDialog");
    buttonMessageDialog.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            MessageDialog dialog = new MessageDialog(getShell(), "Select your favorite Java UI framework", null,
                    "Which one of the following is your favorite Java UI framework?", MessageDialog.QUESTION,
                    new String[] { "AWT", "Swing", "SWT/JFace" }, 2);
            int answer = dialog.open();

            switch (answer) {
            case -1: // if the user closes the dialog without clicking any button.
                System.out.println("No selection");
                break;

            case 0:
                System.out.println("Your selection is: AWT");
                break;
            case 1:
                System.out.println("Your selection is: Swing");
                break;
            case 2:
                System.out.println("Your selection is: SWT/JFace");
                break;

            }
        }
    });

    /* ------ InputDialog ------------- */
    final Button buttonInputDialog = new Button(composite, SWT.PUSH);
    buttonInputDialog.setText("Demo: InputDialog");
    buttonInputDialog.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            IInputValidator validator = new IInputValidator() {
                public String isValid(String newText) {
                    if (newText.equalsIgnoreCase("SWT/JFace") || newText.equalsIgnoreCase("AWT")
                            || newText.equalsIgnoreCase("Swing"))
                        return null;
                    else
                        return "The allowed values are: SWT/JFace, AWT, Swing";
                }
            };
            InputDialog dialog = new InputDialog(getShell(), "Question",
                    "What's your favorite Java UI framework?", "SWT/JFace", validator);
            if (dialog.open() == Window.OK) {
                System.out.println("Your favorite Java UI framework is: " + dialog.getValue());
            } else {
                System.out.println("Action cancelled");
            }
        }
    });

    /* ------ ProgressMonitorDialog ------------- */
    final Button buttonProgressDialog = new Button(composite, SWT.PUSH);
    buttonProgressDialog.setText("Demo: ProgressMonitorDialog");
    buttonProgressDialog.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    monitor.beginTask("Number counting", 10);
                    for (int i = 0; i < 10; i++) {
                        if (monitor.isCanceled()) {
                            monitor.done();
                            return;
                        }

                        System.out.println("Count number: " + i);
                        monitor.worked(1);
                        Thread.sleep(500); // 0.5s.
                    }
                    monitor.done();
                }
            };

            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            try {
                dialog.run(true, true, runnableWithProgress);
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    });
    return super.createContents(parent);
}

From source file:AdvancedBrowser.java

public AdvancedBrowser(String location) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Advanced Browser");

    shell.setLayout(new FormLayout());

    Composite controls = new Composite(shell, SWT.NONE);
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    controls.setLayoutData(data);//ww w . jav a  2 s .  co m

    Label status = new Label(shell, SWT.NONE);
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    status.setLayoutData(data);

    final Browser browser = new Browser(shell, SWT.BORDER);
    data = new FormData();
    data.top = new FormAttachment(controls);
    data.bottom = new FormAttachment(status);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    browser.setLayoutData(data);

    controls.setLayout(new GridLayout(7, false));

    Button button = new Button(controls, SWT.PUSH);
    button.setText("Back");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.back();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Forward");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.forward();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Refresh");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.refresh();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Stop");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.stop();
        }
    });

    final Text url = new Text(controls, SWT.BORDER);
    url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    url.setFocus();

    button = new Button(controls, SWT.PUSH);
    button.setText("Go");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.setUrl(url.getText());
        }
    });

    Label throbber = new Label(controls, SWT.NONE);
    throbber.setText(AT_REST);

    shell.setDefaultButton(button);

    browser.addCloseWindowListener(new AdvancedCloseWindowListener());
    browser.addLocationListener(new AdvancedLocationListener(url));
    browser.addProgressListener(new AdvancedProgressListener(throbber));
    browser.addStatusTextListener(new AdvancedStatusTextListener(status));

    // Go to the initial URL
    if (location != null) {
        browser.setUrl(location);
    }

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

From source file:ShowMessageBox.java

/**
 * Creates the main window's contents/*from   w w  w  .  j a v  a 2 s.c  om*/
 * 
 * @param shell the parent shell
 */
private void createContents(final Shell shell) {
    shell.setLayout(new GridLayout(2, false));

    // Create the dropdown to allow icon selection
    new Label(shell, SWT.NONE).setText("Icon:");
    final Combo icons = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (int i = 0, n = ICONS.length; i < n; i++)
        icons.add(ICONS[i]);
    icons.select(0);

    // Create the dropdown to allow button selection
    new Label(shell, SWT.NONE).setText("Buttons:");
    final Combo buttons = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (int i = 0, n = BUTTONS.length; i < n; i++)
        buttons.add(BUTTONS[i]);
    buttons.select(0);

    // Create the entry field for the message
    new Label(shell, SWT.NONE).setText("Message:");
    final Text message = new Text(shell, SWT.BORDER);
    message.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the label to show the return from the open call
    new Label(shell, SWT.NONE).setText("Return:");
    final Label returnVal = new Label(shell, SWT.NONE);
    returnVal.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the button and event handler
    // to display the message box
    Button button = new Button(shell, SWT.PUSH);
    button.setText("Show Message");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Clear any previously returned value
            returnVal.setText("");

            // This will hold the style to pass to the MessageBox constructor
            int style = 0;

            // Determine which icon was selected and
            // add it to the style
            switch (icons.getSelectionIndex()) {
            case 0:
                style |= SWT.ICON_ERROR;
                break;
            case 1:
                style |= SWT.ICON_INFORMATION;
                break;
            case 2:
                style |= SWT.ICON_QUESTION;
                break;
            case 3:
                style |= SWT.ICON_WARNING;
                break;
            case 4:
                style |= SWT.ICON_WORKING;
                break;
            }

            // Determine which set of buttons was selected
            // and add it to the style
            switch (buttons.getSelectionIndex()) {
            case 0:
                style |= SWT.OK;
                break;
            case 1:
                style |= SWT.OK | SWT.CANCEL;
                break;
            case 2:
                style |= SWT.YES | SWT.NO;
                break;
            case 3:
                style |= SWT.YES | SWT.NO | SWT.CANCEL;
                break;
            case 4:
                style |= SWT.RETRY | SWT.CANCEL;
                break;
            case 5:
                style |= SWT.ABORT | SWT.RETRY | SWT.IGNORE;
                break;
            }

            // Display the message box
            MessageBox mb = new MessageBox(shell, style);
            mb.setText("Message from SWT");
            mb.setMessage(message.getText());
            int val = mb.open();
            String valString = "";
            switch (val) // val contains the constant of the selected button
            {
            case SWT.OK:
                valString = "SWT.OK";
                break;
            case SWT.CANCEL:
                valString = "SWT.CANCEL";
                break;
            case SWT.YES:
                valString = "SWT.YES";
                break;
            case SWT.NO:
                valString = "SWT.NO";
                break;
            case SWT.RETRY:
                valString = "SWT.RETRY";
                break;
            case SWT.ABORT:
                valString = "SWT.ABORT";
                break;
            case SWT.IGNORE:
                valString = "SWT.IGNORE";
                break;
            }
            returnVal.setText(valString);
        }
    });
}