.
*/
public class ChangeHandler implements ChangeListener {
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
public void stateChanged(ChangeEvent e) {
changeListener.stateChanged(e);
}
}
/**
* Listener for resizing events.
*
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of .
*/
public class ComponentHandler extends ComponentAdapter {
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
public void componentResized(ComponentEvent e) {
//getHandler().componentResized(e);
}
};
/**
* Focus-change listener.
*
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of .
*/
public class FocusHandler implements FocusListener {
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
public void focusGained(FocusEvent e) {
//getHandler().focusGained(e);
}
public void focusLost(FocusEvent e) {
//getHandler().focusLost(e);
}
}
public class TrackListener extends MouseInputAdapter {
protected transient int offset;
protected transient int currentMouseX, currentMouseY;
protected transient boolean dragLeft, dragRight;
public void mouseReleased(MouseEvent e) {
isDragging = false;
dragLeft = false;
dragRight = false;
}
/**
* If the mouse is pressed above the "thumb" component
* then reduce the scrollbars value by one page ("page up"),
* otherwise increase it by one page. If there is no
* thumb then page up if the mouse is in the upper half
* of the track.
*/
public void mousePressed(MouseEvent e) {
if (!slider.isEnabled()) {
return;
}
currentMouseX = e.getX();
currentMouseY = e.getY();
// Clicked in the Thumb area?
if (thumbRectLeft.contains(currentMouseX, currentMouseY)) {
offset = currentMouseX - thumbRectLeft.x;
isDragging = true;
} else {
isDragging = false;
}
}
/**
* Set the models value to the position of the top/left
* of the thumb relative to the origin of the track.
*/
public void mouseDragged(MouseEvent e) {
if (!slider.isEnabled()) {
return;
}
currentMouseX = e.getX();
currentMouseY = e.getY();
if (isDragging) {
slider.setValueLeft(e.getX() - offset);
}
}
public void mouseMoved(MouseEvent e) { }
}
}