javax.swing.plaf.basic
Class BasicSliderUI.TrackListener

java.lang.Object
  extended by javax.swing.event.MouseInputAdapter
      extended by javax.swing.plaf.basic.BasicSliderUI.TrackListener
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener, MouseInputListener
Enclosing class:
BasicSliderUI

public class BasicSliderUI.TrackListener
extends MouseInputAdapter

Helper class that listens for mouse events.


Field Summary
protected  int currentMouseX
          The current X position of the mouse.
protected  int currentMouseY
          The current Y position of the mouse.
protected  int offset
          The offset between the current slider value and the cursor's position.
 
Constructor Summary
BasicSliderUI.TrackListener()
           
 
Method Summary
 void mouseDragged(MouseEvent e)
          Called when the mouse has been dragged.
 void mouseMoved(MouseEvent e)
          Called when the mouse has moved over a component but no buttons have been pressed yet.
 void mousePressed(MouseEvent e)
          Called when the mouse is pressed.
 void mouseReleased(MouseEvent e)
          Called when the mouse is released.
 boolean shouldScroll(int direction)
          Indicates whether the thumb should scroll in the given direction.
 
Methods inherited from class javax.swing.event.MouseInputAdapter
mouseClicked, mouseEntered, mouseExited
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.

Constructor Detail

BasicSliderUI.TrackListener

public BasicSliderUI.TrackListener()
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 JSlider accordingly.

Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class MouseInputAdapter
Parameters:
e - A MouseEvent

mouseMoved

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

Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class MouseInputAdapter
Parameters:
e - A MouseEvent

mousePressed

public void mousePressed(MouseEvent e)
Called when the mouse is pressed. When the press occurs on the thumb itself, the 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.

Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseInputAdapter
Parameters:
e - A MouseEvent

mouseReleased

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

Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseInputAdapter
Parameters:
e - A 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.