Java Code Examples for org.eclipse.swt.widgets.Spinner#setDigits()
The following examples show how to use
org.eclipse.swt.widgets.Spinner#setDigits() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SankeySelectionDialog.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void createCutoffSpinner(FormToolkit tk, Composite comp) { tk.createLabel(comp, M.DontShowSmallerThen); Composite inner = tk.createComposite(comp); UI.gridLayout(inner, 2, 10, 0); Spinner spinner = new Spinner(inner, SWT.BORDER); spinner.setIncrement(100); spinner.setMinimum(0); spinner.setMaximum(100000); spinner.setDigits(3); spinner.setSelection((int) (cutoff * 100000)); spinner.addModifyListener(e -> { cutoff = spinner.getSelection() / 100000d; }); tk.adapt(spinner); tk.createLabel(inner, "%"); }
Example 2
Source File: PageSettingDialog.java From ermasterr with Apache License 2.0 | 5 votes |
private void setMarginSpinner(final Spinner spinner) { spinner.setDigits(1); spinner.setIncrement(5); spinner.setMinimum(0); spinner.setMaximum(1000); spinner.setSelection(20); }
Example 3
Source File: PageSettingDialog.java From erflute with Apache License 2.0 | 5 votes |
private void setMarginSpinner(Spinner spinner) { spinner.setDigits(1); spinner.setIncrement(5); spinner.setMinimum(0); spinner.setMaximum(1000); spinner.setSelection(20); }
Example 4
Source File: PageSettingDialog.java From ermaster-b with Apache License 2.0 | 5 votes |
private void setMarginSpinner(Spinner spinner) { spinner.setDigits(1); spinner.setIncrement(5); spinner.setMinimum(0); spinner.setMaximum(1000); spinner.setSelection(20); }
Example 5
Source File: HorizontalSpinnerSnippet.java From nebula with Eclipse Public License 2.0 | 4 votes |
private static void createSpinnerGroup(final Shell shell) { final Group group = new Group(shell, SWT.NONE); group.setLayout(new GridLayout(1, false)); final Label lbl1 = new Label(group, SWT.NONE); lbl1.setText("Simple vertical spinner :"); final Spinner spinner1 = new Spinner(group, SWT.BORDER); spinner1.setMinimum(0); spinner1.setMaximum(1000); spinner1.setSelection(500); spinner1.setIncrement(1); spinner1.setPageIncrement(100); final Label lbl2 = new Label(group, SWT.NONE); lbl2.setText("Floating point values in Spinner :"); final Spinner spinner2 = new Spinner(group, SWT.NONE); // allow 3 decimal places spinner2.setDigits(3); // set the minimum value to 0.001 spinner2.setMinimum(1); // set the maximum value to 20 spinner2.setMaximum(20000); // set the increment value to 0.010 spinner2.setIncrement(10); // set the seletion to 3.456 spinner2.setSelection(3456); spinner2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final int selection = spinner2.getSelection(); final int digits = spinner2.getDigits(); System.out.println("Selection is " + selection / Math.pow(10, digits)); } }); final Label lbl3 = new Label(group, SWT.NONE); lbl3.setText("Validate input in a spinner widget :"); final Spinner spinner3 = new Spinner(group, SWT.BORDER); spinner3.setValues(0, -100, 100, 0, 1, 10); spinner3.setLayoutData(new GridData(200, SWT.DEFAULT)); final ToolTip toolTip = new ToolTip(shell, SWT.BALLOON | SWT.ICON_WARNING); spinner3.addModifyListener(e -> { final String string = spinner3.getText(); String message = null; try { final int value = Integer.parseInt(string); final int maximum = spinner3.getMaximum(); final int minimum = spinner3.getMinimum(); if (value > maximum) { message = "Current input is greater than the maximum limit (" + maximum + ")"; } else if (value < minimum) { message = "Current input is less than the minimum limit (" + minimum + ")"; } } catch (final Exception ex) { message = "Current input is not numeric"; } if (message != null) { spinner3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_RED)); final Rectangle rect = spinner3.getBounds(); final GC gc = new GC(spinner3); final Point pt = gc.textExtent(string); gc.dispose(); toolTip.setLocation(shell.getDisplay().map(shell, null, rect.x + pt.x, rect.y + rect.height)); toolTip.setMessage(message); toolTip.setVisible(true); } else { toolTip.setVisible(false); spinner3.setForeground(null); } }); }