September 2005
Beginner
576 pages
13h 6m
English
To monitor the use of a slider in a Java program, you must have a class that implements the ChangeListener interface, which is part of the javax.swing.event package of classes. This interface includes only one method, which takes the following form:
public void stateChanged(ChangeEvent evt) {
// statements to handle the event
}
To register an object as a change listener, call the addChangeListener(Object) method of the container that holds the slider. When the slider is moved, the listening object's stateChanged() method will be called.
This method is called with a ChangeEvent object that can be used to identify the slider component that was changed in value. Call the object's getSource() method and cast the object to a JSlider ...
Read now
Unlock full access