Home Tutorials Swt SWT Spinner
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

SWT Spinner

Advertisement
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

     

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

     

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 3, 2008

Ask Questions?    Discuss: SWT Spinner  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com