org.tbee.swing
Class ToolTipListener
java.lang.Object
org.tbee.swing.ToolTipListener
- All Implemented Interfaces:
- java.awt.event.AdjustmentListener, java.awt.event.ComponentListener, java.awt.event.MouseWheelListener, java.util.EventListener
public class ToolTipListener
- extends java.lang.Object
- implements java.awt.event.ComponentListener, java.awt.event.MouseWheelListener, java.awt.event.AdjustmentListener
This class is used to help generate tooltips on components added to a
scrollpane. Generally tooltips are generated as the mouse if moved over
components that display tooltips. On complex component, like a JTable
the component can generate multiple tooltips depending on which cell the
mouse is positioned over.
However, when the viewport of the scrollpane is moved and the mouse is
not moved the tooltip is not updated even though the mouse is positioned
over a different cell. This might happen for example when the mouse wheel
is used to scroll the viewport.
To force updating of the tooltip, this class will generate a phantom
mouseMoved event which is passed to the ToolTipManager.
This class is actually a 3 in 1 listener and will work slightly different
depending on how it is being used. When used as a:
a) MouseWheelListener - it is added to the scrollpane. In this case the
mouseMoved events are only generated by scrolling of the mouse wheel
and therefore only supports vertical movement of the viewport
scrollPane.addMouseWheelListener(new ToolTipListener());
b) AdjustmentListener - is added to the vertical and/or horizontal scrollbar.
In this case the viewport can be scrolled by using the mouse wheel or
the keyboard and mouseMoved events will be generated.
scrollPane.getVerticalScrollBar().addAdjustmentListener(new ToolTipListener());
c) ComponentListener - it is added to the component. In this case all forms
of viewport movement as well as changes in the component size will cause
the mouseMoved event to be generated.
table.addComponentListener(new ToolTipListener());
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ToolTipListener
public ToolTipListener()
componentMoved
public void componentMoved(java.awt.event.ComponentEvent e)
- Specified by:
componentMoved in interface java.awt.event.ComponentListener
componentResized
public void componentResized(java.awt.event.ComponentEvent e)
- Specified by:
componentResized in interface java.awt.event.ComponentListener
componentHidden
public void componentHidden(java.awt.event.ComponentEvent e)
- Specified by:
componentHidden in interface java.awt.event.ComponentListener
componentShown
public void componentShown(java.awt.event.ComponentEvent e)
- Specified by:
componentShown in interface java.awt.event.ComponentListener
mouseWheelMoved
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
- Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener
adjustmentValueChanged
public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
- Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener
Copyright © 2010 KnowledgePlaza. All Rights Reserved.