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.eclipse.swt.examples.controlexample.ExpandBarTab.java

/**
 * Creates the "Example" widgets./*from   w w w .  ja va2s. c o m*/
 */
@Override
void createExampleWidgets() {

    /* Compute the widget style */
    int style = getDefaultStyle();
    if (borderButton.getSelection())
        style |= SWT.BORDER;
    if (verticalButton.getSelection())
        style |= SWT.V_SCROLL;

    /* Create the example widgets */
    expandBar1 = new ExpandBar(expandBarGroup, style);

    // First item
    Composite composite = new Composite(expandBar1, SWT.NONE);
    composite.setLayout(new GridLayout());
    new Button(composite, SWT.PUSH).setText("SWT.PUSH");
    new Button(composite, SWT.RADIO).setText("SWT.RADIO");
    new Button(composite, SWT.CHECK).setText("SWT.CHECK");
    new Button(composite, SWT.TOGGLE).setText("SWT.TOGGLE");
    ExpandItem item = new ExpandItem(expandBar1, SWT.NONE, 0);
    item.setText(ControlExample.getResourceString("Item1_Text"));
    item.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
    item.setControl(composite);
    item.setImage(instance.images[ControlExample.ciClosedFolder]);

    // Second item
    composite = new Composite(expandBar1, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    new Label(composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_ERROR));
    new Label(composite, SWT.NONE).setText("SWT.ICON_ERROR");
    new Label(composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_INFORMATION));
    new Label(composite, SWT.NONE).setText("SWT.ICON_INFORMATION");
    new Label(composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_WARNING));
    new Label(composite, SWT.NONE).setText("SWT.ICON_WARNING");
    new Label(composite, SWT.NONE).setImage(display.getSystemImage(SWT.ICON_QUESTION));
    new Label(composite, SWT.NONE).setText("SWT.ICON_QUESTION");
    item = new ExpandItem(expandBar1, SWT.NONE, 1);
    item.setText(ControlExample.getResourceString("Item2_Text"));
    item.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
    item.setControl(composite);
    item.setImage(instance.images[ControlExample.ciOpenFolder]);
    item.setExpanded(true);
}

From source file:org.eclipse.swt.examples.browserexample.BrowserExample.java

public BrowserExample(Composite parent, boolean top) {
    this.parent = parent;
    try {/* w  w  w  .j av  a2 s  .  co m*/
        browser = new Browser(parent, SWT.BORDER);
    } catch (SWTError e) {
        error = e;
        /* Browser widget could not be instantiated */
        parent.setLayout(new FillLayout());
        Label label = new Label(parent, SWT.CENTER | SWT.WRAP);
        label.setText(getResourceString("BrowserNotCreated"));
        label.requestLayout();
        return;
    }
    initResources();
    final Display display = parent.getDisplay();
    browser.setData("org.eclipse.swt.examples.browserexample.BrowserApplication", this);
    browser.addOpenWindowListener(event -> {
        Shell shell = new Shell(display);
        if (icon != null)
            shell.setImage(icon);
        shell.setLayout(new FillLayout());
        BrowserExample app = new BrowserExample(shell, false);
        app.setShellDecoration(icon, true);
        event.browser = app.getBrowser();
    });
    if (top) {
        browser.setUrl(getResourceString("Startup"));
        show(false, null, null, true, true, true, true);
    } else {
        browser.addVisibilityWindowListener(VisibilityWindowListener.showAdapter(e -> {
            Browser browser = (Browser) e.widget;
            BrowserExample app = (BrowserExample) browser
                    .getData("org.eclipse.swt.examples.browserexample.BrowserApplication");
            app.show(true, e.location, e.size, e.addressBar, e.menuBar, e.statusBar, e.toolBar);
        }));
        browser.addCloseWindowListener(event -> {
            Browser browser = (Browser) event.widget;
            Shell shell = browser.getShell();
            shell.close();
        });
    }
}

From source file:TabbedShellExample.java

public GridComposite(Composite c) {
    super(c, SWT.BORDER);
    GridLayout gl = new GridLayout();
    gl.numColumns = 3;//ww w .  j a  va 2s .  co  m
    this.setLayout(gl);
    final Label l1 = new Label(this, SWT.BORDER);
    l1.setText("Column One");
    final Label l2 = new Label(this, SWT.BORDER);
    l2.setText("Column Two");
    final Label l3 = new Label(this, SWT.BORDER);
    l3.setText("Column Three");
    final Text t1 = new Text(this, SWT.SINGLE | SWT.BORDER);
    final Text t2 = new Text(this, SWT.SINGLE | SWT.BORDER);
    final Text t3 = new Text(this, SWT.SINGLE | SWT.BORDER);
    final Text t4 = new Text(this, SWT.SINGLE | SWT.BORDER);
    final Text t5 = new Text(this, SWT.SINGLE | SWT.BORDER);
    final Text t6 = new Text(this, SWT.SINGLE | SWT.BORDER);

    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    l1.setLayoutData(gd);

    gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    l2.setLayoutData(gd);

    gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    l3.setLayoutData(gd);

    gd = new GridData(GridData.FILL_HORIZONTAL);
    t1.setLayoutData(gd);

    gd = new GridData(GridData.FILL_HORIZONTAL);
    t2.setLayoutData(gd);

    gd = new GridData(GridData.FILL_HORIZONTAL);
    t3.setLayoutData(gd);

    gd = new GridData(GridData.FILL_HORIZONTAL);
    t4.setLayoutData(gd);

    gd = new GridData(GridData.FILL_HORIZONTAL);
    t5.setLayoutData(gd);

    gd = new GridData(GridData.FILL_HORIZONTAL);
    t6.setLayoutData(gd);
}

From source file:grafici.PazientiTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart.  This example uses monthly data.
 *
 * @param title  the frame title.//ww  w  .j av a 2  s.  co  m
 */
public PazientiTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);

    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));
    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:org.eclipse.swt.examples.addressbook.DataEntryDialog.java

private void createTextWidgets() {
    if (labels == null)
        return;/*from  w w  w.j a va2  s  . co  m*/

    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    composite.setLayout(layout);

    if (values == null)
        values = new String[labels.length];

    for (int i = 0; i < labels.length; i++) {
        Label label = new Label(composite, SWT.RIGHT);
        label.setText(labels[i]);
        Text text = new Text(composite, SWT.BORDER);
        GridData gridData = new GridData();
        gridData.widthHint = 400;
        text.setLayoutData(gridData);
        if (values[i] != null) {
            text.setText(values[i]);
        }
        text.setData("index", Integer.valueOf(i));
        addTextListener(text);
    }
}

From source file:ShowPrefs.java

/**
 * Creates the controls for this page/* www. j  ava 2 s  . c om*/
 */
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:Survey.java

/**
 * Creates the controls for this page//w ww . ja v  a2  s.co  m
 */
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    new Label(composite, SWT.LEFT).setText("Please enter your complaints");
    Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    text.setLayoutData(new GridData(GridData.FILL_BOTH));

    setControl(composite);
}

From source file:grafici.FattureTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * //from w  w  w .j a  v  a 2  s.c o  m
 * @param title
 *            the frame title.
 */
public FattureTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    System.out.println(2);
    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));
    JPanel chartPanel = createPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:grafici.MediciTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * /*ww w.j  ava  2s .  com*/
 * @param title
 *            the frame title.
 */
public MediciTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);

    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));
    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

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

/**
 * Handles a mouseDown event.//from  w  w w .  j a va  2s .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();
        }
    }
}