|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.event.MouseAdapter
uk.co.keang.swingaddons.HoverDetector
public class HoverDetector
A mouse listener to determine if a mouse is hovering over a component and if so
to perform an action such as popping a dialog.
Hovering is defined as the mouse entering a component and staying still
for a predetermined amount of time. Once the hover has been detected this detector will not
trigger again until the mouse has exited from the component and re-entered it.
This instance will register itself with the appropriate mouse listeners on the owning component.
To de-register this hover detector from the owning component call the remove() method. Once removed
this hover detector can't be used again.
The action taken when a hover is detected is defined in the Callable object. If a window is
displayed then returning a reference to the window from the Callable object will allow this
hover detector to spot when this window no longer has focus and to close the window and
reset the hover detector appropriately. If this functionality is not required return null, if
an alternative functionality is required override the handleObject(Object obj) method.
Constructor Summary | |
---|---|
HoverDetector(java.awt.Component parent,
java.util.concurrent.Callable<java.awt.Component> r)
Creates a hover detector and registers it with component. |
|
HoverDetector(java.awt.Component parent,
java.util.concurrent.Callable<java.awt.Component> r,
int time)
Creates a hover detector and registers it with the component. |
Method Summary | |
---|---|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mouseMoved(java.awt.event.MouseEvent e)
|
void |
remove()
De-registers the hover detector from the component. |
void |
reset()
Forcibly resets the trigger mechanism. |
Methods inherited from class java.awt.event.MouseAdapter |
---|
mouseClicked, mouseDragged, mousePressed, mouseReleased, mouseWheelMoved |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HoverDetector(java.awt.Component parent, java.util.concurrent.Callable<java.awt.Component> r)
parent
- - the component to register for hover detectionr
- - the command to run on hover detectionpublic HoverDetector(java.awt.Component parent, java.util.concurrent.Callable<java.awt.Component> r, int time)
parent
- - the component to register for hover detectionr
- - the command to run on hover detectiontime
- - the delay time before triggering a hoverMethod Detail |
---|
public void remove()
public void reset()
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
mouseEntered
in class java.awt.event.MouseAdapter
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
mouseMoved
in class java.awt.event.MouseAdapter
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
mouseExited
in class java.awt.event.MouseAdapter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |