Example usage for org.eclipse.swt.widgets Label Label

List of usage examples for org.eclipse.swt.widgets Label Label

Introduction

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

Prototype

public Label(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.mwc.debrief.dis.views.DisListenerView.java

@Override
public void createPartControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    composite.setLayoutData(gd);// w  ww. j a v a 2 s .  c om
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);

    Composite buttonComposite = new Composite(composite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    gd.widthHint = 300;
    buttonComposite.setLayoutData(gd);
    layout = new GridLayout(4, false);
    layout.marginWidth = 5;
    layout.marginHeight = 5;
    buttonComposite.setLayout(layout);

    connectButton = createButton(buttonComposite, "Connect", 2);
    connectButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME connect
        }

    });
    disconnectButton = createButton(buttonComposite, "Disconnect", 2);
    disconnectButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME disconnect
        }

    });

    final Link link = new Link(buttonComposite, SWT.NONE);
    gd = new GridData(SWT.END, SWT.FILL, false, false);
    gd.horizontalSpan = 4;
    link.setLayoutData(gd);
    link.setText("<a href=\"id\">Server Prefs</a>");
    link.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(link.getShell(), DisPrefs.ID,
                    null, null);
            dialog.open();
        }
    });
    link.setToolTipText("Dis Preferences");

    stopButton = createButton(buttonComposite, "Stop");
    stopButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME stop
        }

    });

    pauseButton = createButton(buttonComposite, "Pause");
    pauseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME pause
        }

    });

    resumeButton = createButton(buttonComposite, "Resume");
    resumeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME resume
        }

    });

    playButton = createButton(buttonComposite, "Play");
    playButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME play
        }

    });

    stopButton.setEnabled(false);
    pauseButton.setEnabled(false);
    resumeButton.setEnabled(false);
    disconnectButton.setEnabled(false);

    Label label = new Label(buttonComposite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    label.setLayoutData(gd);
    label.setText("Path to input file:");

    Text text = new Text(buttonComposite, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    gd.horizontalSpan = 2;
    gd.widthHint = 150;
    text.setLayoutData(gd);

    final Button browseButton = new Button(buttonComposite, SWT.PUSH);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    browseButton.setLayoutData(gd);
    browseButton.setText("Browse...");
    browseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(getSite().getShell(), SWT.SINGLE);
            String value = pathText.getText();
            if (value.trim().length() == 0) {
                value = Platform.getLocation().toOSString();
            }
            dialog.setFilterPath(value);

            String result = dialog.open();
            if (result == null || result.trim().length() == 0) {
                return;
            }
            pathText.setText(result);

        }

    });

    Composite chartWrapperComposite = new Composite(composite, SWT.BORDER);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    chartWrapperComposite.setLayoutData(gd);
    layout = new GridLayout(1, false);
    chartWrapperComposite.setLayout(layout);

    chartComposite = new ChartComposite(chartWrapperComposite, SWT.NONE, null, 400, 600, 300, 200, 1800, 1800,
            true, true, true, true, true, true) {
        @Override
        public void mouseUp(MouseEvent event) {
            super.mouseUp(event);
            JFreeChart c = getChart();
            if (c != null) {
                c.setNotify(true); // force redraw
            }
        }
    };

    Composite checkboxComposite = new Composite(composite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    checkboxComposite.setLayoutData(gd);
    layout = new GridLayout(2, false);
    layout.marginWidth = 5;
    layout.marginHeight = 5;
    checkboxComposite.setLayout(layout);

    newPlotButton = new Button(checkboxComposite, SWT.CHECK);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    newPlotButton.setLayoutData(gd);
    newPlotButton.setText("New plot per replication");
    newPlotButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME new plot ...
        }

    });
    liveUpdatesButton = new Button(checkboxComposite, SWT.CHECK);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    liveUpdatesButton.setLayoutData(gd);
    liveUpdatesButton.setText("Live updates");
    liveUpdatesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME Live updates.
        }

    });
    liveUpdatesButton.setSelection(true);

}

From source file:PmpEditor.java

/**
 * Creates the main window's contents/*from ww w  .  j  a v  a 2  s. c o m*/
 * 
 * @param shell
 *          the main window
 */
private void createContents(Shell shell) {
    // Set the layout and the menu bar
    shell.setLayout(new FormLayout());
    shell.setMenuBar(new PmpEditorMenu(shell).getMenu());

    // Create the status bar
    status = new Label(shell, SWT.BORDER);
    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    data.height = status.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    status.setLayoutData(data);

    // Create the styled text
    st = new StyledText(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    data = new FormData();
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    data.top = new FormAttachment(0);
    data.bottom = new FormAttachment(status);
    st.setLayoutData(data);

    // Set the font
    st.setFont(font);

    // Add Brief delete next word
    // Use SWT.MOD1 instead of SWT.CTRL for portability
    st.setKeyBinding('k' | SWT.MOD1, ST.DELETE_NEXT);

    // Add vi end of line (kind of)
    // Use SWT.MOD1 instead of SWT.CTRL for portability
    // Use SWT.MOD2 instead of SWT.SHIFT for portability
    // Shift+4 is $
    st.setKeyBinding('4' | SWT.MOD1 | SWT.MOD2, ST.LINE_END);

    // Handle key presses
    st.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent event) {
            // Update the status bar
            updateStatus();
        }
    });

    // Handle text modifications
    st.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            // Update the status bar
            updateStatus();

            // Update the comments
            if (lineStyleListener != null) {
                lineStyleListener.refreshMultilineComments(st.getText());
                st.redraw();
            }
        }
    });

    // Store undo information
    st.addExtendedModifyListener(new ExtendedModifyListener() {
        public void modifyText(ExtendedModifyEvent event) {
            if (!ignoreUndo) {
                // Push this change onto the changes stack
                changes.push(new TextChange(event.start, event.length, event.replacedText));
                if (changes.size() > UNDO_LIMIT)
                    changes.remove(0);
            }
        }
    });

    // Update the title bar and the status bar
    updateTitle();
    updateStatus();
}

From source file:ConnectionInfo.java

protected Control createDialogArea(Composite parent) {
    getShell().setText("Connection Settings");

    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(2, false));

    new Label(composite, SWT.NULL).setText("Host: ");
    textHost = new Text(composite, SWT.BORDER);
    textHost.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new Label(composite, SWT.NULL).setText("Port: ");
    textPort = new Text(composite, SWT.BORDER);
    textPort.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new Label(composite, SWT.NULL).setText("Username: ");
    textUsername = new Text(composite, SWT.BORDER);
    textUsername.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new Label(composite, SWT.NULL).setText("Password: ");
    textPassword = new Text(composite, SWT.PASSWORD | SWT.BORDER);
    textPassword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // sets initial values.
    try {//from   ww  w  .jav  a 2 s .  com
        textHost.setText(dialogSettings.get(KEY_HOST));
        textPort.setText(dialogSettings.getInt(KEY_PORT) + "");
        textUsername.setText(dialogSettings.get(KEY_USERNAME));
        textPassword.setText(dialogSettings.get(KEY_PASSWORD));
    } catch (Exception e) {
        // ignore.
    }

    return composite;
}

From source file:BackupFiles.java

/**
 * Helper method to create the label/text/button for a directory
 * /*from ww w  . j  av a 2 s . c  o m*/
 * @param composite
 *            the parent composite
 * @param label
 *            the text for the label
 * @return Text
 */
private Text createFilePanelHelper(Composite composite, String label) {
    // Create the composite to hold the controls
    Composite panel = new Composite(composite, SWT.BORDER);
    panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    panel.setLayout(new GridLayout(3, false));

    // Create the controls
    new Label(panel, SWT.LEFT).setText(label);
    Text text = new Text(panel, SWT.BORDER);
    text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Button browse = new Button(panel, SWT.PUSH);

    // Add browsing
    browse.setText("...");
    browse.addSelectionListener(new DirectoryBrowser(text));

    // Return the Text that holds the directory
    return text;
}

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

/**
 * Standard constructor: builds a composite for displaying/editing 
 * the properties of the specified axis.
 *
 * @param parent The parent composite./*from   ww w  .java2s .com*/
 * @param style The SWT style of the SwtAxisEditor.
 * @param axis  the axis whose properties are to be displayed/edited  
 *              in the composite.
 */
public SWTAxisEditor(Composite parent, int style, Axis axis) {
    super(parent, style);
    this.labelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getLabelFont(), true);
    this.labelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getLabelPaint());
    this.tickLabelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getTickLabelFont(), true);
    this.tickLabelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getTickLabelPaint());

    FillLayout layout = new FillLayout(SWT.VERTICAL);
    layout.marginHeight = layout.marginWidth = 4;
    this.setLayout(layout);
    Group general = new Group(this, SWT.NONE);
    general.setLayout(new GridLayout(3, false));
    general.setText(localizationResources.getString("General"));
    // row 1
    new Label(general, SWT.NONE).setText(localizationResources.getString("Label"));
    this.label = new Text(general, SWT.BORDER);
    if (axis.getLabel() != null) {
        this.label.setText(axis.getLabel());
    }
    this.label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    new Label(general, SWT.NONE).setText(""); //empty cell
    // row 2
    new Label(general, SWT.NONE).setText(localizationResources.getString("Font"));
    this.labelFontField = new Text(general, SWT.BORDER);
    this.labelFontField.setText(this.labelFont.toString());
    this.labelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectFontButton = new Button(general, SWT.PUSH);
    selectFontButton.setText(localizationResources.getString("Select..."));
    selectFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.labelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title 
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                //label.setFont( font );
                SWTAxisEditor.this.labelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    // row 3
    new Label(general, SWT.NONE).setText(localizationResources.getString("Paint"));
    // Use a colored text field to show the color
    final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.labelPaintColor);
    GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    canvasGridData.heightHint = 20;
    colorCanvas.setLayoutData(canvasGridData);
    Button selectColorButton = new Button(general, SWT.PUSH);
    selectColorButton.setText(localizationResources.getString("Select..."));
    selectColorButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Title_Color"));
            dlg.setRGB(SWTAxisEditor.this.labelPaintColor.getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                // create the new color and set it to the 
                // SwtPaintCanvas
                SWTAxisEditor.this.labelPaintColor = new Color(getDisplay(), rgb);
                colorCanvas.setColor(SWTAxisEditor.this.labelPaintColor);
            }
        }
    });
    Group other = new Group(this, SWT.NONE);
    FillLayout tabLayout = new FillLayout();
    tabLayout.marginHeight = tabLayout.marginWidth = 4;
    other.setLayout(tabLayout);
    other.setText(localizationResources.getString("Other"));

    this.otherTabs = new TabFolder(other, SWT.NONE);
    TabItem item1 = new TabItem(this.otherTabs, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Ticks") + " ");
    Composite ticks = new Composite(this.otherTabs, SWT.NONE);
    ticks.setLayout(new GridLayout(3, false));
    this.showTickLabelsCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickLabelsCheckBox.setText(localizationResources.getString("Show_tick_labels"));
    this.showTickLabelsCheckBox.setSelection(axis.isTickLabelsVisible());
    this.showTickLabelsCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    new Label(ticks, SWT.NONE).setText(localizationResources.getString("Tick_label_font"));
    this.tickLabelFontField = new Text(ticks, SWT.BORDER);
    this.tickLabelFontField.setText(this.tickLabelFont.toString());
    //tickLabelFontField.setFont(SwtUtils.toSwtFontData(getDisplay(), 
    // axis.getTickLabelFont()));
    this.tickLabelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectTickLabelFontButton = new Button(ticks, SWT.PUSH);
    selectTickLabelFontButton.setText(localizationResources.getString("Select..."));
    selectTickLabelFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the font-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.tickLabelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title 
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                //tickLabelFontField.setFont(font);
                SWTAxisEditor.this.tickLabelFontField
                        .setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    this.showTickMarksCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickMarksCheckBox.setText(localizationResources.getString("Show_tick_marks"));
    this.showTickMarksCheckBox.setSelection(axis.isTickMarksVisible());
    this.showTickMarksCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    item1.setControl(ticks);
}

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

/**
 * Standard constructor: builds a composite for displaying/editing
 * the properties of the specified axis.
 * //  w ww. j  a v  a 2s.co  m
 * @param parent
 *            The parent composite.
 * @param style
 *            The SWT style of the SwtAxisEditor.
 * @param axis
 *            the axis whose properties are to be displayed/edited
 *            in the composite.
 */
public SWTAxisEditor(Composite parent, int style, Axis axis) {
    super(parent, style);
    this.labelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getLabelFont(), true);
    this.labelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getLabelPaint());
    this.tickLabelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getTickLabelFont(), true);
    this.tickLabelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getTickLabelPaint());

    FillLayout layout = new FillLayout(SWT.VERTICAL);
    layout.marginHeight = layout.marginWidth = 4;
    setLayout(layout);
    Group general = new Group(this, SWT.NONE);
    general.setLayout(new GridLayout(3, false));
    general.setText(localizationResources.getString("General"));
    // row 1
    new Label(general, SWT.NONE).setText(localizationResources.getString("Label"));
    this.label = new Text(general, SWT.BORDER);
    if (axis.getLabel() != null) {
        this.label.setText(axis.getLabel());
    }
    this.label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    new Label(general, SWT.NONE).setText(""); // empty cell
    // row 2
    new Label(general, SWT.NONE).setText(localizationResources.getString("Font"));
    this.labelFontField = new Text(general, SWT.BORDER);
    this.labelFontField.setText(this.labelFont.toString());
    this.labelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectFontButton = new Button(general, SWT.PUSH);
    selectFontButton.setText(localizationResources.getString("Select..."));
    selectFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.labelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                // label.setFont(font);
                SWTAxisEditor.this.labelFontField.setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    // row 3
    new Label(general, SWT.NONE).setText(localizationResources.getString("Paint"));
    // Use a colored text field to show the color
    final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.labelPaintColor);
    GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    canvasGridData.heightHint = 20;
    colorCanvas.setLayoutData(canvasGridData);
    Button selectColorButton = new Button(general, SWT.PUSH);
    selectColorButton.setText(localizationResources.getString("Select..."));
    selectColorButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Title_Color"));
            dlg.setRGB(SWTAxisEditor.this.labelPaintColor.getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                // create the new color and set it to the
                // SwtPaintCanvas
                SWTAxisEditor.this.labelPaintColor = new Color(getDisplay(), rgb);
                colorCanvas.setColor(SWTAxisEditor.this.labelPaintColor);
            }
        }
    });
    Group other = new Group(this, SWT.NONE);
    FillLayout tabLayout = new FillLayout();
    tabLayout.marginHeight = tabLayout.marginWidth = 4;
    other.setLayout(tabLayout);
    other.setText(localizationResources.getString("Other"));

    this.otherTabs = new TabFolder(other, SWT.NONE);
    TabItem item1 = new TabItem(this.otherTabs, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Ticks") + " ");
    Composite ticks = new Composite(this.otherTabs, SWT.NONE);
    ticks.setLayout(new GridLayout(3, false));
    this.showTickLabelsCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickLabelsCheckBox.setText(localizationResources.getString("Show_tick_labels"));
    this.showTickLabelsCheckBox.setSelection(axis.isTickLabelsVisible());
    this.showTickLabelsCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    new Label(ticks, SWT.NONE).setText(localizationResources.getString("Tick_label_font"));
    this.tickLabelFontField = new Text(ticks, SWT.BORDER);
    this.tickLabelFontField.setText(this.tickLabelFont.toString());
    // tickLabelFontField.setFont(SwtUtils.toSwtFontData(getDisplay(),
    // axis.getTickLabelFont()));
    this.tickLabelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    Button selectTickLabelFontButton = new Button(ticks, SWT.PUSH);
    selectTickLabelFontButton.setText(localizationResources.getString("Select..."));
    selectTickLabelFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the font-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTAxisEditor.this.tickLabelFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTAxisEditor.this.font != null) {
                    SWTAxisEditor.this.font.dispose();
                }
                // Create the new font and set it into the title
                // label
                SWTAxisEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                // tickLabelFontField.setFont(font);
                SWTAxisEditor.this.tickLabelFontField
                        .setText(SWTAxisEditor.this.font.getFontData()[0].toString());
                SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0];
            }
        }
    });
    this.showTickMarksCheckBox = new Button(ticks, SWT.CHECK);
    this.showTickMarksCheckBox.setText(localizationResources.getString("Show_tick_marks"));
    this.showTickMarksCheckBox.setSelection(axis.isTickMarksVisible());
    this.showTickMarksCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    item1.setControl(ticks);
}

From source file:MainClass.java

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

    new Label(composite, SWT.LEFT).setText("First Name:");
    final Text first = new Text(composite, SWT.BORDER);
    first.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new Label(composite, SWT.LEFT).setText("Last Name:");
    final Text last = new Text(composite, SWT.BORDER);
    last.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    first.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            firstName = first.getText();
            setPageComplete(firstName.length() > 0 && lastName.length() > 0);
        }/*from w w  w.  j a  v a  2s  .c o  m*/
    });

    last.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            lastName = last.getText();
            setPageComplete(firstName.length() > 0 && lastName.length() > 0);
        }
    });

    setControl(composite);
}

From source file:org.eclipse.swt.examples.clipboard.ClipboardExample.java

public void open(Display display) {
    clipboard = new Clipboard(display);
    shell = new Shell(display);
    shell.setText("SWT Clipboard");
    shell.setLayout(new FillLayout());

    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
    Composite parent = new Composite(sc, SWT.NONE);
    sc.setContent(parent);//w  w  w.j a  v a2  s.c o  m
    parent.setLayout(new GridLayout(2, true));

    Group copyGroup = new Group(parent, SWT.NONE);
    copyGroup.setText("Copy From:");
    GridData data = new GridData(GridData.FILL_BOTH);
    copyGroup.setLayoutData(data);
    copyGroup.setLayout(new GridLayout(3, false));

    Group pasteGroup = new Group(parent, SWT.NONE);
    pasteGroup.setText("Paste To:");
    data = new GridData(GridData.FILL_BOTH);
    pasteGroup.setLayoutData(data);
    pasteGroup.setLayout(new GridLayout(3, false));

    Group controlGroup = new Group(parent, SWT.NONE);
    controlGroup.setText("Control API:");
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    controlGroup.setLayoutData(data);
    controlGroup.setLayout(new GridLayout(5, false));

    Group typesGroup = new Group(parent, SWT.NONE);
    typesGroup.setText("Available Types");
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    typesGroup.setLayoutData(data);
    typesGroup.setLayout(new GridLayout(2, false));

    status = new Label(parent, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    status.setLayoutData(data);

    createTextTransfer(copyGroup, pasteGroup);
    createRTFTransfer(copyGroup, pasteGroup);
    createHTMLTransfer(copyGroup, pasteGroup);
    createFileTransfer(copyGroup, pasteGroup);
    createImageTransfer(copyGroup, pasteGroup);
    createMyTransfer(copyGroup, pasteGroup);
    createControlTransfer(controlGroup);
    createAvailableTypes(typesGroup);

    sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);

    Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Rectangle monitorArea = shell.getMonitor().getClientArea();
    shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20));
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    clipboard.dispose();
}

From source file:org.eclipse.swt.snippets.Snippet367.java

private static void createSeparator(Composite shell) {
    new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL)
            .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
}

From source file:Menus.java

/**
 * Creates the No Radio Group pop-up menu
 * //from w w w  .  ja  va 2s .  c  om
 * @param shell the main window
 */
private void createNoRadioGroupPopUpMenu(Shell shell) {
    // Create a composite that the pop-up menu will be
    // associated with
    Label label = new Label(shell, SWT.BORDER);
    label.setText("No Radio Group Menu");

    // Create the pop-up menu with the No Radio Group style
    Menu menu = new Menu(shell, SWT.POP_UP | SWT.NO_RADIO_GROUP);
    label.setMenu(menu);

    // Create all the items in the pop-up menu
    MenuItem item1 = new MenuItem(menu, SWT.RADIO);
    item1.setText("Radio One");
    MenuItem item2 = new MenuItem(menu, SWT.RADIO);
    item2.setText("Radio Two");
    MenuItem item3 = new MenuItem(menu, SWT.RADIO);
    item3.setText("Radio Three");

    // Set the pop-up menu as the pop-up for the label
    label.setMenu(menu);
}