Search in sources :

Example 31 with Spinner

use of org.eclipse.swt.widgets.Spinner in project eclipse.platform.swt by eclipse.

the class ControlsWithLabelsExample method main.

public static void main(String[] args) {
    display = new Display();
    shell = new Shell(display);
    shell.setLayout(new GridLayout(4, true));
    shell.setText("All Controls Test");
    new Label(shell, SWT.NONE).setText("Label for Label");
    label = new Label(shell, SWT.NONE);
    label.setText("Label");
    new Label(shell, SWT.NONE).setText("Label for CLabel");
    cLabel = new CLabel(shell, SWT.NONE);
    cLabel.setText("CLabel");
    new Label(shell, SWT.NONE).setText("Label for Push Button");
    buttonPush = new Button(shell, SWT.PUSH);
    buttonPush.setText("Push Button");
    new Label(shell, SWT.NONE).setText("Label for Radio Button");
    buttonRadio = new Button(shell, SWT.RADIO);
    buttonRadio.setText("Radio Button");
    new Label(shell, SWT.NONE).setText("Label for Check Button");
    buttonCheck = new Button(shell, SWT.CHECK);
    buttonCheck.setText("Check Button");
    new Label(shell, SWT.NONE).setText("Label for Toggle Button");
    buttonToggle = new Button(shell, SWT.TOGGLE);
    buttonToggle.setText("Toggle Button");
    new Label(shell, SWT.NONE).setText("Label for Editable Combo");
    combo = new Combo(shell, SWT.BORDER);
    for (int i = 0; i < 4; i++) {
        combo.add("item" + i);
    }
    combo.select(0);
    new Label(shell, SWT.NONE).setText("Label for Read-Only Combo");
    combo = new Combo(shell, SWT.READ_ONLY | SWT.BORDER);
    for (int i = 0; i < 4; i++) {
        combo.add("item" + i);
    }
    combo.select(0);
    new Label(shell, SWT.NONE).setText("Label for CCombo");
    cCombo = new CCombo(shell, SWT.BORDER);
    for (int i = 0; i < 5; i++) {
        cCombo.add("item" + i);
    }
    cCombo.select(0);
    new Label(shell, SWT.NONE).setText("Label for List");
    list = new List(shell, SWT.SINGLE | SWT.BORDER);
    list.setItems("Item0", "Item1", "Item2");
    new Label(shell, SWT.NONE).setText("Label for Spinner");
    spinner = new Spinner(shell, SWT.BORDER);
    new Label(shell, SWT.NONE).setText("Label for Single-line Text");
    textSingle = new Text(shell, SWT.SINGLE | SWT.BORDER);
    textSingle.setText("Contents of Single-line Text");
    new Label(shell, SWT.NONE).setText("Label for Multi-line Text");
    textMulti = new Text(shell, SWT.MULTI | SWT.BORDER);
    textMulti.setText("\nContents of Multi-line Text\n");
    new Label(shell, SWT.NONE).setText("Label for StyledText");
    styledText = new StyledText(shell, SWT.MULTI | SWT.BORDER);
    styledText.setText("\nContents of Multi-line StyledText\n");
    new Label(shell, SWT.NONE).setText("Label for Table");
    table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    for (int col = 0; col < 3; col++) {
        TableColumn column = new TableColumn(table, SWT.NONE);
        column.setText("Col " + col);
        column.setWidth(50);
    }
    for (int row = 0; row < 3; row++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText(new String[] { "C0R" + row, "C1R" + row, "C2R" + row });
    }
    new Label(shell, SWT.NONE).setText("Label for Tree");
    tree = new Tree(shell, SWT.BORDER | SWT.MULTI);
    for (int i = 0; i < 3; i++) {
        TreeItem item = new TreeItem(tree, SWT.NONE);
        item.setText("Item" + i);
        for (int j = 0; j < 4; j++) {
            new TreeItem(item, SWT.NONE).setText("Item" + i + j);
        }
    }
    new Label(shell, SWT.NONE).setText("Label for Tree with columns");
    treeTable = new Tree(shell, SWT.BORDER | SWT.MULTI);
    treeTable.setHeaderVisible(true);
    treeTable.setLinesVisible(true);
    for (int col = 0; col < 3; col++) {
        TreeColumn column = new TreeColumn(treeTable, SWT.NONE);
        column.setText("Col " + col);
        column.setWidth(50);
    }
    for (int i = 0; i < 3; i++) {
        TreeItem item = new TreeItem(treeTable, SWT.NONE);
        item.setText(new String[] { "I" + i + "C0", "I" + i + "C1", "I" + i + "C2" });
        for (int j = 0; j < 4; j++) {
            new TreeItem(item, SWT.NONE).setText(new String[] { "I" + i + j + "C0", "I" + i + j + "C1", "I" + i + j + "C2" });
        }
    }
    new Label(shell, SWT.NONE).setText("Label for ToolBar");
    toolBar = new ToolBar(shell, SWT.FLAT);
    for (int i = 0; i < 3; i++) {
        ToolItem item = new ToolItem(toolBar, SWT.PUSH);
        item.setText("Item" + i);
        item.setToolTipText("ToolItem ToolTip" + i);
    }
    new Label(shell, SWT.NONE).setText("Label for CoolBar");
    coolBar = new CoolBar(shell, SWT.FLAT);
    for (int i = 0; i < 2; i++) {
        CoolItem coolItem = new CoolItem(coolBar, SWT.PUSH);
        ToolBar coolItemToolBar = new ToolBar(coolBar, SWT.FLAT);
        int toolItemWidth = 0;
        for (int j = 0; j < 2; j++) {
            ToolItem item = new ToolItem(coolItemToolBar, SWT.PUSH);
            item.setText("Item" + i + j);
            item.setToolTipText("ToolItem ToolTip" + i + j);
            if (item.getWidth() > toolItemWidth)
                toolItemWidth = item.getWidth();
        }
        coolItem.setControl(coolItemToolBar);
        Point size = coolItemToolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        Point coolSize = coolItem.computeSize(size.x, size.y);
        coolItem.setMinimumSize(toolItemWidth, coolSize.y);
        coolItem.setPreferredSize(coolSize);
        coolItem.setSize(coolSize);
    }
    new Label(shell, SWT.NONE).setText("Label for Canvas");
    canvas = new Canvas(shell, SWT.BORDER);
    canvas.setLayoutData(new GridData(64, 64));
    canvas.addPaintListener(e -> e.gc.drawString("Canvas", 15, 25));
    canvas.setCaret(new Caret(canvas, SWT.NONE));
    /* Hook key listener so canvas will take focus during traversal in. */
    canvas.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }
    });
    /* Hook traverse listener to make canvas give up focus during traversal out. */
    canvas.addTraverseListener(e -> e.doit = true);
    new Label(shell, SWT.NONE).setText("Label for Group");
    group = new Group(shell, SWT.NONE);
    group.setText("Group");
    group.setLayout(new FillLayout());
    new Text(group, SWT.SINGLE | SWT.BORDER).setText("Text in Group");
    new Label(shell, SWT.NONE).setText("Label for TabFolder");
    tabFolder = new TabFolder(shell, SWT.NONE);
    for (int i = 0; i < 3; i++) {
        TabItem item = new TabItem(tabFolder, SWT.NONE);
        item.setText("TabItem &" + i);
        item.setToolTipText("TabItem ToolTip" + i);
        Text itemText = new Text(tabFolder, SWT.SINGLE | SWT.BORDER);
        itemText.setText("Text for TabItem " + i);
        item.setControl(itemText);
    }
    new Label(shell, SWT.NONE).setText("Label for CTabFolder");
    cTabFolder = new CTabFolder(shell, SWT.BORDER);
    for (int i = 0; i < 3; i++) {
        CTabItem item = new CTabItem(cTabFolder, SWT.NONE);
        item.setText("CTabItem &" + i);
        item.setToolTipText("CTabItem ToolTip" + i);
        Text itemText = new Text(cTabFolder, SWT.SINGLE | SWT.BORDER);
        itemText.setText("Text for CTabItem " + i);
        item.setControl(itemText);
    }
    cTabFolder.setSelection(cTabFolder.getItem(0));
    new Label(shell, SWT.NONE).setText("Label for Scale");
    scale = new Scale(shell, SWT.NONE);
    new Label(shell, SWT.NONE).setText("Label for Slider");
    slider = new Slider(shell, SWT.NONE);
    new Label(shell, SWT.NONE).setText("Label for ProgressBar");
    progressBar = new ProgressBar(shell, SWT.NONE);
    progressBar.setSelection(50);
    new Label(shell, SWT.NONE).setText("Label for Sash");
    sash = new Sash(shell, SWT.NONE);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) Group(org.eclipse.swt.widgets.Group) CTabFolder(org.eclipse.swt.custom.CTabFolder) Slider(org.eclipse.swt.widgets.Slider) TreeItem(org.eclipse.swt.widgets.TreeItem) Spinner(org.eclipse.swt.widgets.Spinner) TableItem(org.eclipse.swt.widgets.TableItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) CCombo(org.eclipse.swt.custom.CCombo) Combo(org.eclipse.swt.widgets.Combo) CTabItem(org.eclipse.swt.custom.CTabItem) KeyEvent(org.eclipse.swt.events.KeyEvent) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) CoolBar(org.eclipse.swt.widgets.CoolBar) Button(org.eclipse.swt.widgets.Button) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) List(org.eclipse.swt.widgets.List) CoolItem(org.eclipse.swt.widgets.CoolItem) ProgressBar(org.eclipse.swt.widgets.ProgressBar) ToolItem(org.eclipse.swt.widgets.ToolItem) StyledText(org.eclipse.swt.custom.StyledText) Table(org.eclipse.swt.widgets.Table) Sash(org.eclipse.swt.widgets.Sash) Canvas(org.eclipse.swt.widgets.Canvas) TabFolder(org.eclipse.swt.widgets.TabFolder) CTabFolder(org.eclipse.swt.custom.CTabFolder) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Scale(org.eclipse.swt.widgets.Scale) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point) TabItem(org.eclipse.swt.widgets.TabItem) CTabItem(org.eclipse.swt.custom.CTabItem) CCombo(org.eclipse.swt.custom.CCombo) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) Caret(org.eclipse.swt.widgets.Caret) Display(org.eclipse.swt.widgets.Display)

Example 32 with Spinner

use of org.eclipse.swt.widgets.Spinner in project eclipse.platform.swt by eclipse.

the class SpinnerTab method createPageIncrementGroup.

/**
 * Create a group of widgets to control the page increment
 * attribute of the example widget.
 */
void createPageIncrementGroup() {
    /* Create the group */
    Group pageIncrementGroup = new Group(controlGroup, SWT.NONE);
    pageIncrementGroup.setLayout(new GridLayout());
    pageIncrementGroup.setText(ControlExample.getResourceString("Page_Increment"));
    pageIncrementGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    /* Create the Spinner widget */
    pageIncrementSpinner = new Spinner(pageIncrementGroup, SWT.BORDER);
    pageIncrementSpinner.setMaximum(100000);
    pageIncrementSpinner.setSelection(getDefaultPageIncrement());
    pageIncrementSpinner.setPageIncrement(100);
    pageIncrementSpinner.setIncrement(1);
    pageIncrementSpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    /* Add the listeners */
    pageIncrementSpinner.addSelectionListener(widgetSelectedAdapter(event -> setWidgetPageIncrement()));
}
Also used : SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) TabFolder(org.eclipse.swt.widgets.TabFolder) Button(org.eclipse.swt.widgets.Button) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) Spinner(org.eclipse.swt.widgets.Spinner) ControlListener(org.eclipse.swt.events.ControlListener) GridData(org.eclipse.swt.layout.GridData) Widget(org.eclipse.swt.widgets.Widget) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData)

Example 33 with Spinner

use of org.eclipse.swt.widgets.Spinner in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Spinner method test_ConstructorLorg_eclipse_swt_widgets_CompositeI.

@Override
@Test
public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI() {
    try {
        spinner = new Spinner(null, 0);
        fail("No exception thrown for parent == null");
    } catch (IllegalArgumentException e) {
    }
    int[] cases = { 0, SWT.READ_ONLY, SWT.WRAP };
    for (int i = 0; i < cases.length; i++) spinner = new Spinner(shell, cases[i]);
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner) Test(org.junit.Test)

Example 34 with Spinner

use of org.eclipse.swt.widgets.Spinner in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Spinner method setUp.

@Override
@Before
public void setUp() {
    super.setUp();
    spinner = new Spinner(shell, 0);
    setWidget(spinner);
}
Also used : Spinner(org.eclipse.swt.widgets.Spinner) Before(org.junit.Before)

Example 35 with Spinner

use of org.eclipse.swt.widgets.Spinner in project yamcs-studio by yamcs.

the class OPIColorDialog method createRGBEditGroup.

/**
 * @param rightComposite
 */
private void createRGBEditGroup(Composite rightComposite) {
    GridData rgbGD = new GridData();
    rgbGD.horizontalAlignment = org.eclipse.swt.layout.GridData.CENTER;
    rgbGD.grabExcessHorizontalSpace = true;
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    rgbGroup = new Group(rightComposite, SWT.NONE);
    rgbGroup.setLayout(gridLayout);
    redLabel = new Label(rgbGroup, SWT.NONE);
    redLabel.setText("Red");
    redLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
    redLabel.setLayoutData(rgbGD);
    redScale = new Scale(rgbGroup, SWT.NONE);
    redScale.setMaximum(255);
    redScale.setIncrement(1);
    redScale.setPageIncrement(51);
    redSpinner = new Spinner(rgbGroup, SWT.BORDER);
    redSpinner.setMaximum(255);
    redSpinner.setLayoutData(rgbGD);
    greenLabel = new Label(rgbGroup, SWT.NONE);
    greenLabel.setText("Green");
    greenLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GREEN));
    greenLabel.setLayoutData(rgbGD);
    greenScale = new Scale(rgbGroup, SWT.NONE);
    greenScale.setPageIncrement(51);
    greenScale.setMaximum(255);
    greenSpinner = new Spinner(rgbGroup, SWT.BORDER);
    greenSpinner.setMaximum(255);
    greenSpinner.setLayoutData(rgbGD);
    blueLabel = new Label(rgbGroup, SWT.NONE);
    blueLabel.setText("Blue");
    blueLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
    blueScale = new Scale(rgbGroup, SWT.NONE);
    blueScale.setPageIncrement(51);
    blueScale.setMaximum(255);
    blueSpinner = new Spinner(rgbGroup, SWT.BORDER);
    blueSpinner.setMaximum(255);
    setRGBEditValue(opiColor.getRGBValue());
    redScale.addSelectionListener(new RGBEditListener(0));
    redSpinner.addSelectionListener(new RGBEditListener(0));
    greenScale.addSelectionListener(new RGBEditListener(1));
    greenSpinner.addSelectionListener(new RGBEditListener(1));
    blueScale.addSelectionListener(new RGBEditListener(2));
    blueSpinner.addSelectionListener(new RGBEditListener(2));
    rgbGroup.setTabList(new Control[] { redScale, greenScale, blueScale, redSpinner, greenSpinner, blueSpinner });
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Scale(org.eclipse.swt.widgets.Scale)

Aggregations

Spinner (org.eclipse.swt.widgets.Spinner)70 GridLayout (org.eclipse.swt.layout.GridLayout)54 Label (org.eclipse.swt.widgets.Label)54 Button (org.eclipse.swt.widgets.Button)53 Composite (org.eclipse.swt.widgets.Composite)52 GridData (org.eclipse.swt.layout.GridData)51 Group (org.eclipse.swt.widgets.Group)32 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 Text (org.eclipse.swt.widgets.Text)24 Combo (org.eclipse.swt.widgets.Combo)20 SelectionListener (org.eclipse.swt.events.SelectionListener)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 SWT (org.eclipse.swt.SWT)16 ModifyListener (org.eclipse.swt.events.ModifyListener)14 ModifyEvent (org.eclipse.swt.events.ModifyEvent)11 Point (org.eclipse.swt.graphics.Point)11 Control (org.eclipse.swt.widgets.Control)10 CoreException (org.eclipse.core.runtime.CoreException)6 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)6 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)6