javax.swing.plaf.basic

Class BasicSliderUI.TrackListener

public class BasicSliderUI.TrackListener extends MouseInputAdapter

Helper class that listens for mouse events.

UNKNOWN: Apparently this class was intended to be protected, but was made public by a compiler bug and is now public for compatibility.

Field Summary
protected intcurrentMouseX
The current X position of the mouse.
protected intcurrentMouseY
The current Y position of the mouse.
protected intoffset
The offset between the current slider value and the cursor's position.
Method Summary
voidmouseDragged(MouseEvent e)
Called when the mouse has been dragged.
voidmouseMoved(MouseEvent e)
Called when the mouse has moved over a component but no buttons have been pressed yet.
voidmousePressed(MouseEvent e)
Called when the mouse is pressed.
voidmouseReleased(MouseEvent e)
Called when the mouse is released.
booleanshouldScroll(int direction)
Indicates whether the thumb should scroll in the given direction.

Field Detail

currentMouseX

protected int currentMouseX
The current X position of the mouse.

currentMouseY

protected int currentMouseY
The current Y position of the mouse.

offset

protected int offset
The offset between the current slider value and the cursor's position.

Method Detail

mouseDragged

public void mouseDragged(MouseEvent e)
Called when the mouse has been dragged. This should find the mouse's current position and adjust the value of the {@link JSlider} accordingly.

Parameters: e A {@link MouseEvent}

mouseMoved

public void mouseMoved(MouseEvent e)
Called when the mouse has moved over a component but no buttons have been pressed yet.

Parameters: e A {@link MouseEvent}

mousePressed

public void mousePressed(MouseEvent e)
Called when the mouse is pressed. When the press occurs on the thumb itself, the {@link JSlider} should have its value set to where the mouse was pressed. If the press occurs on the track, then the thumb should move one block towards the direction of the mouse.

Parameters: e A {@link MouseEvent}

mouseReleased

public void mouseReleased(MouseEvent e)
Called when the mouse is released. This should stop the timer that scrolls the thumb.

Parameters: e A {@link MouseEvent}

shouldScroll

public boolean shouldScroll(int direction)
Indicates whether the thumb should scroll in the given direction.

Parameters: direction The direction to check.

Returns: True if the thumb should move in that direction.