set the slider's models (range)
i want to set the slider's arrrow in 100.. how can i do that?
Code :
public class NewClass {
public static void setComponents(Container cont) {
JSlider slider = new JSlider(100, 500);
slider.setBounds(50, 50, 300, 50);
slider.setMinorTickSpacing(10);
slider.setMajorTickSpacing(100);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
cont.setLayout(null);
cont.add(slider);
}
public static void showTheWindow() {
JFrame frame = new JFrame();
setComponents(frame.getContentPane());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 200);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
showTheWindow();
}
});
}
}
tnx in advance!
Re: set the slider's models (range)
solved
Code :
JSlider slider = new JSlider (100, 500, 100)
where the third value which is "100", will be the value where the slider's arrow is initialized
hahahaha