SWT Spinner

In SWT, the class Spinner of package org.eclipse.swt.widgets is used. The method setMinimum() sets the minimum value and the method setMaximum() sets the maximum value.

SWT Spinner

SWT Spinner

     

This section illustrates you how to create a spinner in SWT.

In SWT, the class Spinner of package org.eclipse.swt.widgets is used. The method setMinimum() sets the minimum value and the method setMaximum() sets the maximum value. The method setSize() of class Spinner sets the size of spinner. The method setIncrement() the value and the method setPageIncrement() sets the page increment.

Here is the code of SpinnerExample.java

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;

public class SpinnerExample {

  public static void main(String[] args) {
  Display display = new Display();
  Shell shell = new Shell(display);
  shell.setText("Spinner");

  Spinner spin = new Spinner(shell, 0);
  spin.setMinimum(0);
  spin.setMaximum(500);
  spin.setSelection(150);
  spin.setIncrement(1);
  spin.setPageIncrement(200);
  spin.setSize(150,40);

  shell.pack();
  shell.open();
  shell.setSize(17070);
  while (!shell.isDisposed()) {
  if (!display.readAndDispatch())
  display.sleep();
  }
  display.dispose();
  }
} 

Output will be displayed as

Download Source Code