K
kmsterrett
Hello,
In the stateChanged event handling for a slider, if the JSliders value
exceeds a specified value,
I would like to reset it back to the specified value.
Is there some way to cancel the actionPerformed, and set the slider to
the maximumValue?
I cannot user slider.setMaximum to maximumValue, because through out
the program, the maximumValue can change and I do not want the ticks,
etc to change, just beacause I don't want the slider to go any higher.
I hope I have explained myself clearly.
Thanks for any help.
Kim
Here is my code, but the slider is not being set back to the maximum
value.
/** Listen to the slider. */
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider)e.getSource();
int fps = (int)source.getValue();
if (fps >= maximum{
source.setValue(maximumValue -1);
JOptionPane.showMessageDialog(null,"Start Frame cannot
be greater than End Frame." , "Error",
JOptionPane.ERROR_MESSAGE);
Toolkit.getDefaultToolkit().beep();
return;
}
else
System.out.println("Slider is now set to "+fps);
}
In the stateChanged event handling for a slider, if the JSliders value
exceeds a specified value,
I would like to reset it back to the specified value.
Is there some way to cancel the actionPerformed, and set the slider to
the maximumValue?
I cannot user slider.setMaximum to maximumValue, because through out
the program, the maximumValue can change and I do not want the ticks,
etc to change, just beacause I don't want the slider to go any higher.
I hope I have explained myself clearly.
Thanks for any help.
Kim
Here is my code, but the slider is not being set back to the maximum
value.
/** Listen to the slider. */
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider)e.getSource();
int fps = (int)source.getValue();
if (fps >= maximum{
source.setValue(maximumValue -1);
JOptionPane.showMessageDialog(null,"Start Frame cannot
be greater than End Frame." , "Error",
JOptionPane.ERROR_MESSAGE);
Toolkit.getDefaultToolkit().beep();
return;
}
else
System.out.println("Slider is now set to "+fps);
}