I have one slider in my JAVA
application.I have written change listener for that slider. Here is the code i have written
jSlider = new JSlider(JSlider.HORIZONTAL,0,30,2);
jSlider.setFont(new Font("Dialog", Font.BOLD, 10));
jSlider.setMinorTickSpacing(1);
jSlider.setMajorTickSpacing(2);
jSlider.setPaintTicks(true);
jSlider.setPaintLabels(true);
jSlider.setBounds(76, 564, 586, 55);
jSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent arg0) {
// TODO Auto-generated method stub
textField.setText(String.valueOf(jSlider.getValue()));
}
});
getContentPane().add(jSlider);
This code gives the continuous changing values of the slider.
but i want the value of rest position of the slider. What should I write to get the value only for the rest position?
We can also use
Above code also gives the value for the rest position of the slider.