public class HoverTracker
extends java.lang.Object
MouseListener
but unfortunately that strategy only works for simple components with no children. This implementation
puts mouse listeners on the given component and all children, and tracks whenever the mouse is anywhere in the
interior of the outermost component. Note that the tracker does not handle the case where the children are altered
after the tracker is created, so make the tracker after the UI has been initialized.Constructor and Description |
---|
HoverTracker(javax.swing.JComponent component,
java.lang.Runnable onEnter,
java.lang.Runnable onExit) |
Modifier and Type | Method and Description |
---|---|
static HoverTracker |
installHoverBackground(javax.swing.JComponent component,
java.awt.Color normalColor,
java.awt.Color hoverColor) |
static HoverTracker |
installHoverBorder(javax.swing.JComponent component,
javax.swing.border.Border normalBorder,
javax.swing.border.Border hoverBorder) |
void |
uninstall()
Removes the mouse listeners from all the components they were installed on.
|
public HoverTracker(javax.swing.JComponent component, java.lang.Runnable onEnter, java.lang.Runnable onExit)
public static HoverTracker installHoverBackground(javax.swing.JComponent component, java.awt.Color normalColor, java.awt.Color hoverColor)
public static HoverTracker installHoverBorder(javax.swing.JComponent component, javax.swing.border.Border normalBorder, javax.swing.border.Border hoverBorder)
public void uninstall()