Create a vertical slider with min=0, max=100, value=50 in Java
Description
The following code shows how to create a vertical slider with min=0, max=100, value=50.
Example
/*from w w w . j a v a 2s.c om*/
import javax.swing.JFrame;
import javax.swing.JSlider;
public class Main {
public static void main(String[] args) {
JFrame f = new JFrame();
final JSlider slider = new JSlider(JSlider.VERTICAL);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(slider);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »