Example usage for org.eclipse.swt.widgets Composite setLayout

List of usage examples for org.eclipse.swt.widgets Composite setLayout

Introduction

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

Prototype

public void setLayout(Layout layout) 

Source Link

Document

Sets the layout which is associated with the receiver to be the argument which may be null.

Usage

From source file:ShowPrefs.java

/**
 * Creates the controls for this page/*from w  w  w .ja va  2  s. c  o m*/
 */
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new RowLayout(SWT.VERTICAL));

    // Get the preference store
    IPreferenceStore preferenceStore = getPreferenceStore();

    // Create three checkboxes
    checkOne = new Button(composite, SWT.CHECK);
    checkOne.setText("Check One");
    checkOne.setSelection(preferenceStore.getBoolean(ONE));

    checkTwo = new Button(composite, SWT.CHECK);
    checkTwo.setText("Check Two");
    checkTwo.setSelection(preferenceStore.getBoolean(TWO));

    checkThree = new Button(composite, SWT.CHECK);
    checkThree.setText("Check Three");
    checkThree.setSelection(preferenceStore.getBoolean(THREE));

    return composite;
}

From source file:ToolBarComplex.java

/**
 * Creates the window contents/*from  www  .j  a v a  2 s. c o m*/
 * 
 * @param shell the parent shell
 */
private void createContents(Shell shell) {
    shell.setLayout(new RowLayout(SWT.VERTICAL));
    createToolbar(shell);

    // Create the labels to display the statuses of
    // the "check" and "radio" buttons
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayout(new GridLayout(2, true));

    new Label(composite, SWT.RIGHT).setText("Check One Status:");
    checkOneStatus = new Label(composite, SWT.LEFT);
    checkOneStatus.setText("Off");

    new Label(composite, SWT.RIGHT).setText("Check Two Status:");
    checkTwoStatus = new Label(composite, SWT.LEFT);
    checkTwoStatus.setText("Off");

    new Label(composite, SWT.RIGHT).setText("Radio Status:");
    radioStatus = new Label(composite, SWT.LEFT);
    radioStatus.setText("None");
}

From source file:ShowPrefs.java

/**
 * Creates the controls for this page/*from   w w  w.j a  va 2  s. c o m*/
 */
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));

    // Get the preference store
    IPreferenceStore preferenceStore = getPreferenceStore();

    // Create three text fields.
    // Set the text in each from the preference store
    new Label(composite, SWT.LEFT).setText("Field One:");
    fieldOne = new Text(composite, SWT.BORDER);
    fieldOne.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fieldOne.setText(preferenceStore.getString(ONE));

    new Label(composite, SWT.LEFT).setText("Field Two:");
    fieldTwo = new Text(composite, SWT.BORDER);
    fieldTwo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fieldTwo.setText(preferenceStore.getString(TWO));

    new Label(composite, SWT.LEFT).setText("Field Three:");
    fieldThree = new Text(composite, SWT.BORDER);
    fieldThree.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fieldThree.setText(preferenceStore.getString(THREE));

    return composite;
}

From source file:org.eclipse.swt.examples.graphics.RegionClippingTab.java

/**
 * Creates the widgets used to control the drawing.
 *///from   w  ww.j a v a 2 s  .c o m
@Override
public void createControlPanel(Composite parent) {
    // create drop down combo for choosing clipping
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Clipping")); //$NON-NLS-1$
    clippingCb = new Combo(comp, SWT.DROP_DOWN);
    clippingCb.add(GraphicsExample.getResourceString("Region1")); //$NON-NLS-1$
    clippingCb.add(GraphicsExample.getResourceString("Region2")); //$NON-NLS-1$
    clippingCb.add(GraphicsExample.getResourceString("Add")); //$NON-NLS-1$
    clippingCb.add(GraphicsExample.getResourceString("Sub")); //$NON-NLS-1$
    clippingCb.add(GraphicsExample.getResourceString("Inter")); //$NON-NLS-1$
    clippingCb.select(0);
    clippingCb.addListener(SWT.Selection, event -> example.redraw());

    // color menu
    ColorMenu cm = new ColorMenu();
    menu1 = cm.createMenu(parent.getParent(), gb -> {
        colorGB1 = gb;
        colorButton1.setImage(gb.getThumbNail());
        example.redraw();
    });
    menu2 = cm.createMenu(parent.getParent(), gb -> {
        colorGB2 = gb;
        colorButton2.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the color to blue
    colorGB1 = (GraphicsBackground) menu1.getItem(4).getData();
    // initialize the color to red
    colorGB2 = (GraphicsBackground) menu2.getItem(2).getData();

    // color button 1
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    colorButton1 = new Button(comp, SWT.PUSH);
    colorButton1.setText(GraphicsExample.getResourceString("Color1")); //$NON-NLS-1$
    colorButton1.setImage(colorGB1.getThumbNail());
    colorButton1.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu1.setLocation(point.x, point.y + bounds.height);
        menu1.setVisible(true);
    });

    // color button 2
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    colorButton2 = new Button(comp, SWT.PUSH);
    colorButton2.setText(GraphicsExample.getResourceString("Color2")); //$NON-NLS-1$
    colorButton2.setImage(colorGB2.getThumbNail());
    colorButton2.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu2.setLocation(point.x, point.y + bounds.height);
        menu2.setVisible(true);
    });
}

From source file:MainClass.java

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new FillLayout(SWT.VERTICAL));
    new Label(composite, SWT.CENTER).setText("Welcome to the Address Book Entry Wizard!");
    new Label(composite, SWT.LEFT).setText("This wizard guides you through creating an Address Book entry.");
    new Label(composite, SWT.LEFT).setText("Click Next to continue.");
    setControl(composite);//from w  w w. j a v a2s.c om
}

From source file:org.eclipse.swt.examples.graphics.AnimatedGraphicsTab.java

/**
 * Sets the layout of the composite to RowLayout and creates the toolbar.
 *
 * @see org.eclipse.swt.examples.graphics.GraphicsTab#createControlPanel(org.eclipse.swt.widgets.Composite)
 *//*from   www. j  a  v a  2 s  .  c o  m*/
@Override
public void createControlPanel(Composite parent) {

    // setup layout
    RowLayout layout = new RowLayout();
    layout.wrap = true;
    layout.spacing = 8;
    parent.setLayout(layout);

    createToolBar(parent);
}

From source file:org.eclipse.swt.examples.graphics.AnimatedGraphicsTab.java

/**
 * Creates the toolbar controls: play, pause and animation timer.
 *
 * @param parent A composite// ww  w.ja  v  a  2s  . c om
 */
void createToolBar(final Composite parent) {
    final Display display = parent.getDisplay();

    toolBar = new ToolBar(parent, SWT.FLAT);
    Listener toolBarListener = event -> {
        switch (event.type) {
        case SWT.Selection: {
            if (event.widget == playItem) {
                animate = true;
                playItem.setEnabled(!animate);
                pauseItem.setEnabled(animate);
            } else if (event.widget == pauseItem) {
                animate = false;
                playItem.setEnabled(!animate);
                pauseItem.setEnabled(animate);
            }
        }
            break;
        }
    };

    // play tool item
    playItem = new ToolItem(toolBar, SWT.PUSH);
    playItem.setText(GraphicsExample.getResourceString("Play")); //$NON-NLS-1$
    playItem.setImage(example.loadImage(display, "play.gif")); //$NON-NLS-1$
    playItem.addListener(SWT.Selection, toolBarListener);

    // pause tool item
    pauseItem = new ToolItem(toolBar, SWT.PUSH);
    pauseItem.setText(GraphicsExample.getResourceString("Pause")); //$NON-NLS-1$
    pauseItem.setImage(example.loadImage(display, "pause.gif")); //$NON-NLS-1$
    pauseItem.addListener(SWT.Selection, toolBarListener);

    // timer spinner
    Composite comp = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    comp.setLayout(gridLayout);

    Label label = new Label(comp, SWT.CENTER);
    label.setText(GraphicsExample.getResourceString("Animation")); //$NON-NLS-1$
    timerSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    timerSpinner.setMaximum(1000);

    playItem.setEnabled(false);
    animate = true;

    timerSpinner.setSelection(getInitialAnimationTime());
}

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

/**
 * Creates a new editor.//from  w  ww.j a v a 2s  .c om
 * 
 * @param parent  the parent.
 * @param style  the style.
 * @param axis  the axis.
 */
public SWTNumberAxisEditor(Composite parent, int style, NumberAxis axis) {
    super(parent, style, axis);
    this.autoRange = axis.isAutoRange();
    this.minimumValue = axis.getLowerBound();
    this.maximumValue = axis.getUpperBound();

    TabItem item2 = new TabItem(getOtherTabs(), SWT.NONE);
    item2.setText(" " + localizationResources.getString("Range") + " ");
    Composite range = new Composite(getOtherTabs(), SWT.NONE);
    range.setLayout(new GridLayout(2, true));
    item2.setControl(range);

    this.autoRangeCheckBox = new Button(range, SWT.CHECK);
    this.autoRangeCheckBox.setText(localizationResources.getString("Auto-adjust_range"));
    this.autoRangeCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    this.autoRangeCheckBox.setSelection(this.autoRange);
    this.autoRangeCheckBox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            toggleAutoRange();
        }
    });
    new Label(range, SWT.NONE).setText(localizationResources.getString("Minimum_range_value"));
    this.minimumRangeValue = new Text(range, SWT.BORDER);
    this.minimumRangeValue.setText(String.valueOf(this.minimumValue));
    this.minimumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    this.minimumRangeValue.setEnabled(!this.autoRange);
    //this.minimumRangeValue.addModifyListener(this);
    //this.minimumRangeValue.addVerifyListener(this);
    this.minimumRangeValue.addFocusListener(this);
    new Label(range, SWT.NONE).setText(localizationResources.getString("Maximum_range_value"));
    this.maximumRangeValue = new Text(range, SWT.BORDER);
    this.maximumRangeValue.setText(String.valueOf(this.maximumValue));
    this.maximumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    this.maximumRangeValue.setEnabled(!this.autoRange);
    //this.maximumRangeValue.addModifyListener(this);
    //this.maximumRangeValue.addVerifyListener(this);
    this.maximumRangeValue.addFocusListener(this);
}

From source file:org.eclipse.swt.examples.graphics.CustomFontTab.java

@Override
public void createControlPanel(Composite parent) {

    Composite mainComp = new Composite(parent, SWT.NONE);
    mainComp.setLayout(new RowLayout());

    // create combo for font face
    Composite comp = new Composite(mainComp, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    new Label(comp, SWT.LEFT).setText(GraphicsExample.getResourceString("FontFace")); //$NON-NLS-1$
    fontFaceCb = new Combo(comp, SWT.DROP_DOWN);
    for (String name : fontNames) {
        fontFaceCb.add(name);/*www .ja  v  a2 s . c  o m*/
    }
    fontFaceCb.select(0);
    fontFaceCb.addListener(SWT.Selection, event -> example.redraw());

    // create combo for font style
    comp = new Composite(mainComp, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    new Label(comp, SWT.LEFT).setText(GraphicsExample.getResourceString("FontStyle")); //$NON-NLS-1$
    fontStyleCb = new Combo(comp, SWT.DROP_DOWN);
    for (String fontStyle : fontStyles) {
        fontStyleCb.add(fontStyle);
    }
    fontStyleCb.select(0);
    fontStyleCb.addListener(SWT.Selection, event -> example.redraw());

    // create spinner for font size (points)
    comp = new Composite(mainComp, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    new Label(comp, SWT.LEFT).setText(GraphicsExample.getResourceString("FontSize")); //$NON-NLS-1$
    fontPointSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    fontPointSpinner.setMinimum(1);
    fontPointSpinner.setMaximum(1000);
    fontPointSpinner.setSelection(200);
    fontPointSpinner.addListener(SWT.Selection, event -> example.redraw());

    ColorMenu cm = new ColorMenu();
    cm.setColorItems(true);
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        fontForeground = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the background to the 2nd item in the menu (black)
    fontForeground = (GraphicsBackground) menu.getItem(1).getData();

    // create color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());

    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(fontForeground.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}

From source file:DumbUser.java

/**
 * Creates the dialog area/* w  w  w . j  a  v a2s .co  m*/
 * 
 * @param parent the parent composite
 * @return Control
 */
protected Control createDialogArea(Composite parent) {
    createMessageArea(parent);

    // Create a composite to hold the label
    Composite composite = new Composite(parent, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    composite.setLayoutData(data);
    composite.setLayout(new FillLayout());

    // Create the label for the "hidden" message
    label = new Label(composite, SWT.LEFT);

    return composite;
}