javax.swing

Class ToolTipManager

public class ToolTipManager extends MouseAdapter implements MouseMotionListener

This class is responsible for the registration of JToolTips to Components and for displaying them when appropriate.
Nested Class Summary
protected classToolTipManager.insideTimerAction
This ActionListener is associated with the Timer that listens to whether it is time for the JToolTip to be displayed after the mouse has entered the JComponent.
protected classToolTipManager.outsideTimerAction
This Actionlistener is associated with the Timer that listens to whether the mouse cursor has re-entered the JComponent in time for an immediate redisplay of the JToolTip.
protected classToolTipManager.stillInsideTimerAction
This ActionListener is associated with the Timer that listens to whether the JToolTip can be hidden after four seconds.
Field Summary
protected booleanheavyWeightPopupEnabled
heavyWeightPopupEnabled
protected booleanlightWeightPopupEnabled
lightWeightPopupEnabled
Method Summary
intgetDismissDelay()
This method returns the time the ToolTip will be shown before being hidden.
intgetInitialDelay()
This method returns the initial delay before the ToolTip is shown when the mouse enters a Component.
intgetReshowDelay()
This method returns the amount of delay where if the mouse re-enters a Component, the tooltip will be shown immediately.
booleanisEnabled()
This method returns whether ToolTips are enabled.
booleanisLightWeightPopupEnabled()
This method returns whether LightweightToolTips are enabled.
voidmouseDragged(MouseEvent event)
This method is called when the mouse is dragged in a JComponent registered with the ToolTipManager.
voidmouseEntered(MouseEvent event)
This method is called whenever the mouse enters a JComponent registered with the ToolTipManager.
voidmouseExited(MouseEvent event)
This method is called when the mouse exits a JComponent registered with the ToolTipManager.
voidmouseMoved(MouseEvent event)
This method is called when the mouse is moved in a JComponent registered with the ToolTipManager.
voidmousePressed(MouseEvent event)
This method is called when the mouse is pressed on a JComponent registered with the ToolTipManager.
voidregisterComponent(JComponent component)
This method registers a JComponent with the ToolTipManager.
voidsetDismissDelay(int delay)
Sets the time the ToolTip will be shown before being hidden.
voidsetEnabled(boolean enabled)
This method sets whether ToolTips are enabled or disabled for all JComponents.
voidsetInitialDelay(int delay)
Sets the initial delay before the ToolTip is shown when the mouse enters a Component.
voidsetLightWeightPopupEnabled(boolean enabled)
This method sets whether LightweightToolTips are enabled.
voidsetReshowDelay(int delay)
Sets the amount of delay where if the mouse re-enters a Component, the tooltip will be shown immediately.
static ToolTipManagersharedInstance()
This method returns the shared instance of ToolTipManager used by all JComponents.
voidunregisterComponent(JComponent component)
This method unregisters a JComponent with the ToolTipManager.

Field Detail

heavyWeightPopupEnabled

protected boolean heavyWeightPopupEnabled
heavyWeightPopupEnabled

lightWeightPopupEnabled

protected boolean lightWeightPopupEnabled
lightWeightPopupEnabled

Method Detail

getDismissDelay

public int getDismissDelay()
This method returns the time the ToolTip will be shown before being hidden.

Returns: The time the ToolTip will be shown before being hidden.

getInitialDelay

public int getInitialDelay()
This method returns the initial delay before the ToolTip is shown when the mouse enters a Component.

Returns: The initial delay before the ToolTip is shown.

getReshowDelay

public int getReshowDelay()
This method returns the amount of delay where if the mouse re-enters a Component, the tooltip will be shown immediately.

Returns: The reshow delay.

isEnabled

public boolean isEnabled()
This method returns whether ToolTips are enabled.

Returns: Whether ToolTips are enabled.

isLightWeightPopupEnabled

public boolean isLightWeightPopupEnabled()
This method returns whether LightweightToolTips are enabled.

Returns: Whether LighweightToolTips are enabled.

mouseDragged

public void mouseDragged(MouseEvent event)
This method is called when the mouse is dragged in a JComponent registered with the ToolTipManager.

Parameters: event The MouseEvent.

mouseEntered

public void mouseEntered(MouseEvent event)
This method is called whenever the mouse enters a JComponent registered with the ToolTipManager. When the mouse enters within the period of time specified by the reshow delay, the tooltip will be displayed immediately. Otherwise, it must wait for the initial delay before displaying the tooltip.

Parameters: event The MouseEvent.

mouseExited

public void mouseExited(MouseEvent event)
This method is called when the mouse exits a JComponent registered with the ToolTipManager. When the mouse exits, the tooltip should be hidden immediately.

Parameters: event The MouseEvent.

mouseMoved

public void mouseMoved(MouseEvent event)
This method is called when the mouse is moved in a JComponent registered with the ToolTipManager.

Parameters: event The MouseEvent.

mousePressed

public void mousePressed(MouseEvent event)
This method is called when the mouse is pressed on a JComponent registered with the ToolTipManager. When the mouse is pressed, the tooltip (if it is shown) must be hidden immediately.

Parameters: event The MouseEvent.

registerComponent

public void registerComponent(JComponent component)
This method registers a JComponent with the ToolTipManager.

Parameters: component The JComponent to register with the ToolTipManager.

setDismissDelay

public void setDismissDelay(int delay)
Sets the time the ToolTip will be shown before being hidden.

Parameters: delay the delay (in milliseconds) before tool tips are hidden.

Throws: IllegalArgumentException if delay is less than zero.

setEnabled

public void setEnabled(boolean enabled)
This method sets whether ToolTips are enabled or disabled for all JComponents.

Parameters: enabled Whether ToolTips are enabled or disabled for all JComponents.

setInitialDelay

public void setInitialDelay(int delay)
Sets the initial delay before the ToolTip is shown when the mouse enters a Component.

Parameters: delay The initial delay before the ToolTip is shown.

Throws: IllegalArgumentException if delay is less than zero.

setLightWeightPopupEnabled

public void setLightWeightPopupEnabled(boolean enabled)
This method sets whether LightweightToolTips are enabled. If you mix Lightweight and Heavyweight components, you must set this to false to ensure that the ToolTips popup above all other components.

Parameters: enabled Whether LightweightToolTips will be enabled.

setReshowDelay

public void setReshowDelay(int delay)
Sets the amount of delay where if the mouse re-enters a Component, the tooltip will be shown immediately.

Parameters: delay The reshow delay (in milliseconds).

Throws: IllegalArgumentException if delay is less than zero.

sharedInstance

public static ToolTipManager sharedInstance()
This method returns the shared instance of ToolTipManager used by all JComponents.

Returns: The shared instance of ToolTipManager.

unregisterComponent

public void unregisterComponent(JComponent component)
This method unregisters a JComponent with the ToolTipManager.

Parameters: component The JComponent to unregister with the ToolTipManager.