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:org.eclipse.swt.examples.browser.demos.views.EditorTab.java

public EditorTab(TabItem item) {
    final Composite parent = new Composite(item.getParent(), SWT.NONE);
    item.setText("Editor");
    item.setControl(parent);/* www  . j  av  a2 s  .  c om*/

    try {
        browser = new Browser(parent, SWT.NONE);
    } catch (SWTError e) {
        e.printStackTrace();
        return;
    }
    final Sash sash = new Sash(parent, SWT.VERTICAL);
    Composite panel = new Composite(parent, SWT.NONE);
    final FormLayout form = new FormLayout();
    parent.setLayout(form);

    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(sash, 0);
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(100, 0);
    browser.setLayoutData(data);

    final FormData sashData = new FormData();
    sashData.left = new FormAttachment(50, 0);
    sashData.top = new FormAttachment(0, 0);
    sashData.bottom = new FormAttachment(100, 0);
    sash.setLayoutData(sashData);
    sash.addListener(SWT.Selection, e -> {
        Rectangle rect = sash.getBounds();
        Rectangle parentRect = sash.getParent().getClientArea();
        int right = parentRect.width - rect.width - 20;
        e.x = Math.max(Math.min(e.x, right), 20);
        if (e.x != rect.x) {
            sashData.left = new FormAttachment(0, e.x);
            parent.layout();
        }
    });
    data = new FormData();
    data.left = new FormAttachment(sash, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(100, 0);
    panel.setLayoutData(data);

    /* Initialize Panel */
    panel.setLayout(new FillLayout(SWT.VERTICAL));
    Group htmlGroup = new Group(panel, SWT.NONE);
    htmlGroup.setText("setText");
    htmlText = new Text(htmlGroup, SWT.MULTI);
    htmlButton = new Button(htmlGroup, SWT.PUSH);
    htmlButton.setText("setText");
    GridLayout gridLayout = new GridLayout();
    htmlGroup.setLayout(gridLayout);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    htmlText.setLayoutData(gridData);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.END;
    htmlButton.setLayoutData(gridData);
    htmlGroup.layout();

    Group scriptGroup = new Group(panel, SWT.NONE);
    scriptGroup.setText("execute");
    scriptText = new Text(scriptGroup, SWT.MULTI);
    scriptButton = new Button(scriptGroup, SWT.PUSH);
    scriptButton.setText("execute");
    gridLayout = new GridLayout();
    scriptGroup.setLayout(gridLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    scriptText.setLayoutData(gridData);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.END;
    scriptButton.setLayoutData(gridData);
    scriptGroup.layout();

    browser.setText(html);
    htmlText.setText(html);
    scriptText.setText(script);
    parent.layout();

    Listener listener = e -> {
        Widget w = e.widget;
        if (w == htmlButton)
            browser.setText(htmlText.getText());
        if (w == scriptButton)
            browser.execute(scriptText.getText());
    };

    htmlButton.addListener(SWT.Selection, listener);
    scriptButton.addListener(SWT.Selection, listener);
}

From source file:Ch11WizardComposite.java

public void createControl(Composite parent) {
    Composite topLevel = new Composite(parent, SWT.NONE);
    topLevel.setLayout(new GridLayout(2, false));

    Label l = new Label(topLevel, SWT.CENTER);
    l.setText("Use default directory?");

    button = new Button(topLevel, SWT.CHECK);

    setControl(topLevel);//ww  w.j ava  2  s.c om
    setPageComplete(true);
}

From source file:org.eclipse.swt.examples.controlexample.ShellTab.java

/**
 * Handle the Create button selection event.
 *
 * @param event org.eclipse.swt.events.SelectionEvent
 *///from ww w.  j  av a 2 s  .  com
public void createButtonSelected(SelectionEvent event) {

    /*
     * Remember the example shells so they
     * can be disposed by the user.
     */
    if (shellCount >= shells.length) {
        Shell[] newShells = new Shell[shells.length + 4];
        System.arraycopy(shells, 0, newShells, 0, shells.length);
        shells = newShells;
    }

    /* Compute the shell style */
    int style = SWT.NONE;
    if (noTrimButton.getSelection())
        style |= SWT.NO_TRIM;
    if (noMoveButton.getSelection())
        style |= SWT.NO_MOVE;
    if (closeButton.getSelection())
        style |= SWT.CLOSE;
    if (titleButton.getSelection())
        style |= SWT.TITLE;
    if (minButton.getSelection())
        style |= SWT.MIN;
    if (maxButton.getSelection())
        style |= SWT.MAX;
    if (borderButton.getSelection())
        style |= SWT.BORDER;
    if (resizeButton.getSelection())
        style |= SWT.RESIZE;
    if (onTopButton.getSelection())
        style |= SWT.ON_TOP;
    if (toolButton.getSelection())
        style |= SWT.TOOL;
    if (sheetButton.getSelection())
        style |= SWT.SHEET;
    if (modelessButton.getSelection())
        style |= SWT.MODELESS;
    if (primaryModalButton.getSelection())
        style |= SWT.PRIMARY_MODAL;
    if (applicationModalButton.getSelection())
        style |= SWT.APPLICATION_MODAL;
    if (systemModalButton.getSelection())
        style |= SWT.SYSTEM_MODAL;

    /* Create the shell with or without a parent */
    if (noParentButton.getSelection()) {
        shells[shellCount] = new Shell(style);
    } else {
        shells[shellCount] = new Shell(shell, style);
    }
    final Shell currentShell = shells[shellCount];
    currentShell.setBackgroundMode(SWT.INHERIT_DEFAULT);
    final Button button = new Button(currentShell, SWT.CHECK);
    button.setBounds(20, 20, 120, 30);
    button.setText(ControlExample.getResourceString("FullScreen"));
    button.addSelectionListener(widgetSelectedAdapter(e -> currentShell.setFullScreen(button.getSelection())));
    Button close = new Button(currentShell, SWT.PUSH);
    close.setBounds(160, 20, 120, 30);
    close.setText(ControlExample.getResourceString("Close"));
    close.addListener(SWT.Selection, event1 -> {
        currentShell.dispose();
        shellCount--;
    });

    /* Set the size, title, and image, and open the shell */
    currentShell.setSize(300, 100);
    currentShell.setText(ControlExample.getResourceString("Title") + shellCount);
    if (imageButton.getSelection())
        currentShell.setImage(instance.images[ControlExample.ciTarget]);
    if (backgroundImageButton.getSelection())
        currentShell.setBackgroundImage(instance.images[ControlExample.ciBackground]);
    hookListeners(currentShell);
    currentShell.open();
    shellCount++;
}

From source file:org.eclipse.swt.examples.launcher.LauncherView.java

/**
 * Creates the example./*  w ww.jav a  2s .c o  m*/
 * 
 * @see ViewPart#createPartControl
 */
@Override
public void createPartControl(Composite parent) {
    workbenchShell = getSite().getShell();
    parent.setLayout(new SplitLayout());

    Group launchGroup = new Group(parent, SWT.NONE);
    launchGroup.setText(LauncherPlugin.getResourceString("view.launchGroup.text"));

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    launchGroup.setLayout(gridLayout);

    launchTree = new Tree(launchGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    gridData.horizontalSpan = 2;
    launchTree.setLayoutData(gridData);
    launchTree.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            final ItemDescriptor item = getSelectedItem();
            setDescriptionByItem(item);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent event) {
            final ItemDescriptor item = getSelectedItem();
            setDescriptionByItem(item);
            if (item.getMainType() == null && item.getView() == null) {
                // Category selected, so just expand/colapse the node
                TreeItem treeItem = (TreeItem) event.item;
                boolean expanded = treeItem.getExpanded();
                if (treeItem != null)
                    treeItem.setExpanded(!expanded);
                treeItem.setImage(LauncherPlugin.images[expanded ? LauncherPlugin.liClosedFolder
                        : LauncherPlugin.liOpenFolder]);
            } else {
                launchItem(getSelectedItem());
            }
        }
    });
    launchTree.addTreeListener(new TreeListener() {
        @Override
        public void treeCollapsed(TreeEvent event) {
            final TreeItem item = (TreeItem) event.item;
            if (item == null)
                return;
            item.setImage(LauncherPlugin.images[LauncherPlugin.liClosedFolder]);
        }

        @Override
        public void treeExpanded(TreeEvent event) {
            final TreeItem item = (TreeItem) event.item;
            if (item == null)
                return;
            item.setImage(LauncherPlugin.images[LauncherPlugin.liOpenFolder]);
        }
    });

    runButton = new Button(launchGroup, SWT.PUSH);
    runButton.setText(LauncherPlugin.getResourceString("view.launchButton.text"));
    runButton.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            launchItem(getSelectedItem());
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent event) {
        }
    });

    Group descriptionGroup = new Group(parent, SWT.NONE);
    descriptionGroup.setText(LauncherPlugin.getResourceString("view.descriptionGroup.text"));
    descriptionGroup.setLayout(new FillLayout());

    descriptionText = new Text(descriptionGroup,
            SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);

    setDescriptionByItem(null);
    setItemDescriptors(LauncherPlugin.getLaunchItemTree());
}

From source file:CalculatorMichaelSchmidt.java

@Override
protected Control createDialogArea(final Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    final GridLayout calculatorGridLayout = new GridLayout();
    calculatorGridLayout.marginRight = 5;
    calculatorGridLayout.marginLeft = 5;
    calculatorGridLayout.marginBottom = 5;
    calculatorGridLayout.marginTop = 5;//w w w .j ava2 s.com
    calculatorGridLayout.marginWidth = 10;
    calculatorGridLayout.marginHeight = 2;
    calculatorGridLayout.numColumns = 4;
    calculatorGridLayout.verticalSpacing = 2;
    calculatorGridLayout.makeColumnsEqualWidth = true;
    calculatorGridLayout.horizontalSpacing = 2;
    container.setLayout(calculatorGridLayout);

    // The display.  Note that it has a limit of 30 characters, 
    // much greater than the length of a double-precision number. 
    displayText = new Text(container, SWT.RIGHT | SWT.BORDER);
    displayText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    displayText.setEditable(false);
    displayText.setDoubleClickEnabled(false);
    displayText.setTextLimit(30);
    displayText.setText(displayString);
    displayText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 4, 1));

    final Button msButton = new Button(container, SWT.NONE);
    msButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateMemory('S');
        }
    });
    msButton.setToolTipText("Save value to Memory");
    msButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    msButton.setText("MS");

    final Button mcButton = new Button(container, SWT.NONE);
    mcButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('D');
        }
    });
    mcButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    mcButton.setToolTipText("Clear Memory");
    mcButton.setText("MC");

    final Button clearButton = new Button(container, SWT.NONE);
    clearButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('C');
        }
    });
    clearButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    clearButton.setToolTipText("Clear all Calculator Registers");
    clearButton.setText("C");

    final Button ceButton = new Button(container, SWT.NONE);
    ceButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('E');
        }
    });
    ceButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    ceButton.setToolTipText("Clear Entry");
    ceButton.setText("CE");

    final Button memAddButton = new Button(container, SWT.NONE);
    memAddButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateMemory('+');
        }
    });
    memAddButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    memAddButton.setToolTipText("Add value to Memory");
    memAddButton.setText("M+");

    final Button mrButton = new Button(container, SWT.NONE);
    mrButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('R');
        }
    });
    mrButton.setToolTipText("Recall value in Memory");
    mrButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    mrButton.setText("MR");

    final Button backButton = new Button(container, SWT.NONE);
    backButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('B');
        }
    });
    backButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    backButton.setToolTipText("Backspace");
    backButton.setText("BACK");

    final Button divideButton = new Button(container, SWT.NONE);
    divideButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('/');
        }
    });
    divideButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    divideButton.setToolTipText("Divide");
    divideButton.setText("/");

    final Button memSubtractButton = new Button(container, SWT.NONE);
    memSubtractButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateMemory('-');
        }
    });
    memSubtractButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    memSubtractButton.setToolTipText("Subtract value from Memory");
    memSubtractButton.setText("M-");

    final Button inverseButton = new Button(container, SWT.NONE);
    inverseButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('I');
        }
    });
    inverseButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    inverseButton.setToolTipText("Inverse of value");
    inverseButton.setText("1/X");

    final Button sqrtButton = new Button(container, SWT.NONE);
    sqrtButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('Q');
        }
    });
    sqrtButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    sqrtButton.setToolTipText("Square Root of value");
    sqrtButton.setText("SQRT");

    final Button multiplyButton = new Button(container, SWT.NONE);
    multiplyButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('*');
        }
    });
    multiplyButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    multiplyButton.setToolTipText("Multiply");
    multiplyButton.setText("*");

    final Button num7Button = new Button(container, SWT.NONE);
    num7Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('7');
        }
    });
    num7Button.setToolTipText("Numeric Pad");
    num7Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num7Button.setText("7");

    final Button num8Button = new Button(container, SWT.NONE);
    num8Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('8');
        }
    });
    num8Button.setToolTipText("Numeric Pad");
    num8Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num8Button.setText("8");

    final Button num9Button = new Button(container, SWT.NONE);
    num9Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('9');
        }
    });
    num9Button.setToolTipText("Numeric Pad");
    num9Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num9Button.setText("9");

    final Button SubtractButton = new Button(container, SWT.NONE);
    SubtractButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('-');
        }
    });
    SubtractButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    SubtractButton.setToolTipText("Subtract");
    SubtractButton.setText("-");

    final Button num4Button = new Button(container, SWT.NONE);
    num4Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('4');
        }
    });
    num4Button.setToolTipText("Numeric Pad");
    num4Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num4Button.setText("4");

    final Button num5Button = new Button(container, SWT.NONE);
    num5Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('5');
        }
    });
    num5Button.setToolTipText("Numeric Pad");
    num5Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num5Button.setText("5");

    final Button num6Button = new Button(container, SWT.NONE);
    num6Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('6');
        }
    });
    num6Button.setToolTipText("Numeric Pad");
    num6Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num6Button.setText("6");

    final Button AdditionButton = new Button(container, SWT.NONE);
    AdditionButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('+');
        }
    });
    AdditionButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    AdditionButton.setToolTipText("Add");
    AdditionButton.setText("+");

    final Button num1Button = new Button(container, SWT.NONE);
    num1Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('1');
        }
    });
    num1Button.setCapture(true);
    num1Button.setToolTipText("Numeric Pad");
    num1Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num1Button.setText("1");

    final Button num2Button = new Button(container, SWT.NONE);
    num2Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('2');
        }
    });
    num2Button.setToolTipText("Numeric Pad");
    num2Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num2Button.setText("2");

    final Button num3Button = new Button(container, SWT.NONE);
    num3Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('3');
        }
    });
    num3Button.setToolTipText("Numeric Pad");
    num3Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num3Button.setText("3");

    final Button equalsButton = new Button(container, SWT.NONE);
    equalsButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('=');
        }
    });
    equalsButton.setToolTipText("Equals (get result)");
    equalsButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 2));
    equalsButton.setText("=");

    final Button num0Button = new Button(container, SWT.NONE);
    num0Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('0');
        }
    });
    num0Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num0Button.setToolTipText("Numeric Pad");
    num0Button.setText("0");

    final Button decimalButton = new Button(container, SWT.NONE);
    decimalButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('.');
        }
    });
    decimalButton.setToolTipText("Numeric Pad");
    decimalButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    decimalButton.setText(".");

    final Button signButton = new Button(container, SWT.NONE);
    signButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('-');
        }
    });
    signButton.setToolTipText("Change sign of value");
    signButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    signButton.setText("+/-");
    new Label(container, SWT.NONE);
    //
    return container;
}

From source file:ProgressBarDialog.java

protected void createContents() {
    shell = new Shell(getParent(), SWT.TITLE | SWT.PRIMARY_MODAL);
    display = shell.getDisplay();//from w w  w. ja va 2 s. com
    final GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 10;

    shell.setLayout(gridLayout);
    shell.setSize(483, 181);
    shell.setText(shellTitle);

    final Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    composite.setLayout(new GridLayout());

    message = new CLabel(composite, SWT.NONE);
    message.setImage(processImage);
    message.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    message.setText(processMessage);

    progressBarComposite = new Composite(shell, SWT.NONE);
    progressBarComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
    progressBarComposite.setLayout(new FillLayout());

    progressBar = new ProgressBar(progressBarComposite, processBarStyle);
    progressBar.setMaximum(executeTime);

    processMessageLabel = new Label(shell, SWT.NONE);
    processMessageLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
    lineLabel = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    lineLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));

    cancelComposite = new Composite(shell, SWT.NONE);
    cancelComposite.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
    final GridLayout gridLayout_1 = new GridLayout();
    gridLayout_1.numColumns = 2;
    cancelComposite.setLayout(gridLayout_1);

    cancelButton = new Button(cancelComposite, SWT.NONE);
    cancelButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            isClosed = true;
            //System.out.println(isClosed);
        }
    });
    cancelButton.setLayoutData(new GridData(78, SWT.DEFAULT));
    cancelButton.setText("cancel");
    cancelButton.setEnabled(this.mayCancel);

}

From source file:org.eclipse.swt.examples.controlexample.RangeTab.java

/**
 * Creates the "Style" group.//w w w .  j av a 2 s.c  om
 */
@Override
void createStyleGroup() {
    super.createStyleGroup();

    /* Create the extra widgets */
    if (orientationButtons) {
        horizontalButton = new Button(styleGroup, SWT.RADIO);
        horizontalButton.setText("SWT.HORIZONTAL");
        verticalButton = new Button(styleGroup, SWT.RADIO);
        verticalButton.setText("SWT.VERTICAL");
    }
    borderButton = new Button(styleGroup, SWT.CHECK);
    borderButton.setText("SWT.BORDER");
}

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

/**
 * Creates a new editor.// ww  w  . j a  va  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./* www . j  a va2s  .  c  o  m*/
 * 
 * @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:CheckFileTree.java

/**
 * Creates the main window's contents/*from   www .  j a  v a2s .co m*/
 * 
 * @param parent
 *            the main window
 * @return Control
 */
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    // Add a checkbox to toggle whether the labels preserve case
    Button preserveCase = new Button(composite, SWT.CHECK);
    preserveCase.setText("&Preserve case");

    // Create the tree viewer to display the file tree
    final TreeViewer tv = new TreeViewer(composite);
    tv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    tv.setContentProvider(new FileTreeContentProvider());
    tv.setLabelProvider(new FileTreeLabelProvider());
    tv.setInput("root"); // pass a non-null that will be ignored

    // When user checks the checkbox, toggle the preserve case attribute
    // of the label provider
    preserveCase.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            boolean preserveCase = ((Button) event.widget).getSelection();
            FileTreeLabelProvider ftlp = (FileTreeLabelProvider) tv.getLabelProvider();
            ftlp.setPreserveCase(preserveCase);
        }
    });
    return composite;
}