Java examples for Swing:JSlider
Create and use HORIZONTAL Sliders
import javax.swing.JFrame; import javax.swing.JSlider; public class Main extends JFrame { public Main() { super("Slider"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider pickNum = new JSlider(JSlider.HORIZONTAL, 0, 30, 5); pickNum.setMajorTickSpacing(10);// www . j ava 2 s . c o m pickNum.setMinorTickSpacing(1); pickNum.setPaintTicks(true); pickNum.setPaintLabels(true); add(pickNum); pack(); setVisible(true); } public static void main(String[] args) { Main frame = new Main(); } }