javax.swing.plaf.basic

Class BasicSliderUI.TrackListener

Enclosing Class:
BasicSliderUI
Implemented Interfaces:
EventListener, MouseInputListener, MouseListener, MouseMotionListener

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.

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, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

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 Details

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 interface 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 interface 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 interface 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 interface 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.

BasicSliderUI.java -- Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.