Set Slider Min and Max Value : Slider « SWT « Java Tutorial






Set Slider Min and Max Value
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Slider;

public class SliderMinMaxValue {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());


    // Create a horizontal Slider, accepting the defaults
    new Slider(shell, SWT.HORIZONTAL);

    // Create a vertical Slider and set its properties
    Slider slider = new Slider(shell, SWT.VERTICAL);
    slider.setMinimum(0);
    slider.setMaximum(100);
    slider.setIncrement(5);
    slider.setPageIncrement(20);
    slider.setSelection(75);
    
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}








17.25.Slider
17.25.1.Introducing Slider
17.25.2.Set Slider Min and Max ValueSet Slider Min and Max Value