javax.swing
Class ToolTipManager

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.event.MouseAdapter sample code for java.awt.event.MouseAdapter definition code for java.awt.event.MouseAdapter 
      extended by javax.swing.ToolTipManager
All Implemented Interfaces:
MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener , MouseMotionListener sample code for java.awt.event.MouseMotionListener definition code for java.awt.event.MouseMotionListener , EventListener sample code for java.util.EventListener definition code for java.util.EventListener

public class ToolTipManager
extends MouseAdapter sample code for java.awt.event.MouseAdapter definition code for java.awt.event.MouseAdapter
implements MouseMotionListener sample code for java.awt.event.MouseMotionListener definition code for java.awt.event.MouseMotionListener

Manages all the ToolTips in the system.

ToolTipManager contains numerous properties for configuring how long it will take for the tooltips to become visible, and how long till they hide. Consider a component that has a different tooltip based on where the mouse is, such as JTree. When the mouse moves into the JTree and over a region that has a valid tooltip, the tooltip will become visibile after initialDelay milliseconds. After dismissDelay milliseconds the tooltip will be hidden. If the mouse is over a region that has a valid tooltip, and the tooltip is currently visible, when the mouse moves to a region that doesn't have a valid tooltip the tooltip will be hidden. If the mouse then moves back into a region that has a valid tooltip within reshowDelay milliseconds, the tooltip will immediately be shown, otherwise the tooltip will be shown again after initialDelay milliseconds.

See Also:
JComponent.createToolTip() sample code for javax.swing.JComponent.createToolTip() definition code for javax.swing.JComponent.createToolTip()

Nested Class Summary
protected  class ToolTipManager.insideTimerAction sample code for javax.swing.ToolTipManager.insideTimerAction definition code for javax.swing.ToolTipManager.insideTimerAction
           
protected  class ToolTipManager.outsideTimerAction sample code for javax.swing.ToolTipManager.outsideTimerAction definition code for javax.swing.ToolTipManager.outsideTimerAction
           
protected  class ToolTipManager.stillInsideTimerAction sample code for javax.swing.ToolTipManager.stillInsideTimerAction definition code for javax.swing.ToolTipManager.stillInsideTimerAction
           
 
Field Summary
protected  boolean heavyWeightPopupEnabled sample code for javax.swing.ToolTipManager.heavyWeightPopupEnabled definition code for javax.swing.ToolTipManager.heavyWeightPopupEnabled
           
protected  boolean lightWeightPopupEnabled sample code for javax.swing.ToolTipManager.lightWeightPopupEnabled definition code for javax.swing.ToolTipManager.lightWeightPopupEnabled
           
 
Method Summary
 int getDismissDelay sample code for javax.swing.ToolTipManager.getDismissDelay() definition code for javax.swing.ToolTipManager.getDismissDelay() ()
          Returns the dismissal delay value.
 int getInitialDelay sample code for javax.swing.ToolTipManager.getInitialDelay() definition code for javax.swing.ToolTipManager.getInitialDelay() ()
          Returns the initial delay value.
 int getReshowDelay sample code for javax.swing.ToolTipManager.getReshowDelay() definition code for javax.swing.ToolTipManager.getReshowDelay() ()
          Returns the reshow delay property.
 boolean isEnabled sample code for javax.swing.ToolTipManager.isEnabled() definition code for javax.swing.ToolTipManager.isEnabled() ()
          Returns true if this object is enabled.
 boolean isLightWeightPopupEnabled sample code for javax.swing.ToolTipManager.isLightWeightPopupEnabled() definition code for javax.swing.ToolTipManager.isLightWeightPopupEnabled() ()
          Returns true if lightweight (all-Java) Tooltips are in use, or false if heavyweight (native peer) Tooltips are being used.
 void mouseDragged sample code for javax.swing.ToolTipManager.mouseDragged(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mouseDragged(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
          Called when the mouse is pressed and dragged.
 void mouseEntered sample code for javax.swing.ToolTipManager.mouseEntered(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mouseEntered(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
          Called when the mouse enters the region of a component.
 void mouseExited sample code for javax.swing.ToolTipManager.mouseExited(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mouseExited(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
          Called when the mouse exits the region of a component.
 void mouseMoved sample code for javax.swing.ToolTipManager.mouseMoved(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mouseMoved(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
          Called when the mouse is moved.
 void mousePressed sample code for javax.swing.ToolTipManager.mousePressed(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mousePressed(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
          Called when the mouse is pressed.
 void registerComponent sample code for javax.swing.ToolTipManager.registerComponent(javax.swing.JComponent) definition code for javax.swing.ToolTipManager.registerComponent(javax.swing.JComponent) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  component)
          Registers a component for tooltip management.
 void setDismissDelay sample code for javax.swing.ToolTipManager.setDismissDelay(int) definition code for javax.swing.ToolTipManager.setDismissDelay(int) (int milliseconds)
          Specifies the dismissal delay value.
 void setEnabled sample code for javax.swing.ToolTipManager.setEnabled(boolean) definition code for javax.swing.ToolTipManager.setEnabled(boolean) (boolean flag)
          Enables or disables the tooltip.
 void setInitialDelay sample code for javax.swing.ToolTipManager.setInitialDelay(int) definition code for javax.swing.ToolTipManager.setInitialDelay(int) (int milliseconds)
          Specifies the initial delay value.
 void setLightWeightPopupEnabled sample code for javax.swing.ToolTipManager.setLightWeightPopupEnabled(boolean) definition code for javax.swing.ToolTipManager.setLightWeightPopupEnabled(boolean) (boolean aFlag)
          When displaying the JToolTip, the ToolTipManager chooses to use a lightweight JPanel if it fits.
 void setReshowDelay sample code for javax.swing.ToolTipManager.setReshowDelay(int) definition code for javax.swing.ToolTipManager.setReshowDelay(int) (int milliseconds)
          Used to specify the amount of time before the user has to wait initialDelay milliseconds before a tooltip will be shown.
static ToolTipManager sample code for javax.swing.ToolTipManager definition code for javax.swing.ToolTipManager sharedInstance sample code for javax.swing.ToolTipManager.sharedInstance() definition code for javax.swing.ToolTipManager.sharedInstance() ()
          Returns a shared ToolTipManager instance.
 void unregisterComponent sample code for javax.swing.ToolTipManager.unregisterComponent(javax.swing.JComponent) definition code for javax.swing.ToolTipManager.unregisterComponent(javax.swing.JComponent) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  component)
          Removes a component from tooltip control.
 
Methods inherited from class java.awt.event.MouseAdapter sample code for java.awt.event.MouseAdapter definition code for java.awt.event.MouseAdapter
mouseClicked sample code for java.awt.event.MouseAdapter.mouseClicked(java.awt.event.MouseEvent) definition code for java.awt.event.MouseAdapter.mouseClicked(java.awt.event.MouseEvent) , mouseReleased sample code for java.awt.event.MouseAdapter.mouseReleased(java.awt.event.MouseEvent) definition code for java.awt.event.MouseAdapter.mouseReleased(java.awt.event.MouseEvent)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

lightWeightPopupEnabled sample code for javax.swing.ToolTipManager.lightWeightPopupEnabled

protected boolean lightWeightPopupEnabled

heavyWeightPopupEnabled sample code for javax.swing.ToolTipManager.heavyWeightPopupEnabled

protected boolean heavyWeightPopupEnabled
Method Detail

setEnabled sample code for javax.swing.ToolTipManager.setEnabled(boolean) definition code for javax.swing.ToolTipManager.setEnabled(boolean)

public void setEnabled(boolean flag)
Enables or disables the tooltip.

Parameters:
flag - true to enable the tip, false otherwise

isEnabled sample code for javax.swing.ToolTipManager.isEnabled() definition code for javax.swing.ToolTipManager.isEnabled()

public boolean isEnabled()
Returns true if this object is enabled.

Returns:
true if this object is enabled, false otherwise

setLightWeightPopupEnabled sample code for javax.swing.ToolTipManager.setLightWeightPopupEnabled(boolean) definition code for javax.swing.ToolTipManager.setLightWeightPopupEnabled(boolean)

public void setLightWeightPopupEnabled(boolean aFlag)
When displaying the JToolTip, the ToolTipManager chooses to use a lightweight JPanel if it fits. This method allows you to disable this feature. You have to do disable it if your application mixes light weight and heavy weights components.

Parameters:
aFlag - true if a lightweight panel is desired, false otherwise

isLightWeightPopupEnabled sample code for javax.swing.ToolTipManager.isLightWeightPopupEnabled() definition code for javax.swing.ToolTipManager.isLightWeightPopupEnabled()

public boolean isLightWeightPopupEnabled()
Returns true if lightweight (all-Java) Tooltips are in use, or false if heavyweight (native peer) Tooltips are being used.

Returns:
true if lightweight ToolTips are in use

setInitialDelay sample code for javax.swing.ToolTipManager.setInitialDelay(int) definition code for javax.swing.ToolTipManager.setInitialDelay(int)

public void setInitialDelay(int milliseconds)
Specifies the initial delay value.

Parameters:
milliseconds - the number of milliseconds to delay (after the cursor has paused) before displaying the tooltip
See Also:
getInitialDelay() sample code for javax.swing.ToolTipManager.getInitialDelay() definition code for javax.swing.ToolTipManager.getInitialDelay()

getInitialDelay sample code for javax.swing.ToolTipManager.getInitialDelay() definition code for javax.swing.ToolTipManager.getInitialDelay()

public int getInitialDelay()
Returns the initial delay value.

Returns:
an integer representing the initial delay value, in milliseconds
See Also:
setInitialDelay(int) sample code for javax.swing.ToolTipManager.setInitialDelay(int) definition code for javax.swing.ToolTipManager.setInitialDelay(int)

setDismissDelay sample code for javax.swing.ToolTipManager.setDismissDelay(int) definition code for javax.swing.ToolTipManager.setDismissDelay(int)

public void setDismissDelay(int milliseconds)
Specifies the dismissal delay value.

Parameters:
milliseconds - the number of milliseconds to delay before taking away the tooltip
See Also:
getDismissDelay() sample code for javax.swing.ToolTipManager.getDismissDelay() definition code for javax.swing.ToolTipManager.getDismissDelay()

getDismissDelay sample code for javax.swing.ToolTipManager.getDismissDelay() definition code for javax.swing.ToolTipManager.getDismissDelay()

public int getDismissDelay()
Returns the dismissal delay value.

Returns:
an integer representing the dismissal delay value, in milliseconds
See Also:
setDismissDelay(int) sample code for javax.swing.ToolTipManager.setDismissDelay(int) definition code for javax.swing.ToolTipManager.setDismissDelay(int)

setReshowDelay sample code for javax.swing.ToolTipManager.setReshowDelay(int) definition code for javax.swing.ToolTipManager.setReshowDelay(int)

public void setReshowDelay(int milliseconds)
Used to specify the amount of time before the user has to wait initialDelay milliseconds before a tooltip will be shown. That is, if the tooltip is hidden, and the user moves into a region of the same Component that has a valid tooltip within milliseconds milliseconds the tooltip will immediately be shown. Otherwise, if the user moves into a region with a valid tooltip after milliseconds milliseconds, the user will have to wait an additional initialDelay milliseconds before the tooltip is shown again.

Parameters:
milliseconds - time in milliseconds
See Also:
getReshowDelay() sample code for javax.swing.ToolTipManager.getReshowDelay() definition code for javax.swing.ToolTipManager.getReshowDelay()

getReshowDelay sample code for javax.swing.ToolTipManager.getReshowDelay() definition code for javax.swing.ToolTipManager.getReshowDelay()

public int getReshowDelay()
Returns the reshow delay property.

Returns:
reshown delay property
See Also:
setReshowDelay(int) sample code for javax.swing.ToolTipManager.setReshowDelay(int) definition code for javax.swing.ToolTipManager.setReshowDelay(int)

sharedInstance sample code for javax.swing.ToolTipManager.sharedInstance() definition code for javax.swing.ToolTipManager.sharedInstance()

public static ToolTipManager sample code for javax.swing.ToolTipManager definition code for javax.swing.ToolTipManager  sharedInstance()
Returns a shared ToolTipManager instance.

Returns:
a shared ToolTipManager object

registerComponent sample code for javax.swing.ToolTipManager.registerComponent(javax.swing.JComponent) definition code for javax.swing.ToolTipManager.registerComponent(javax.swing.JComponent)

public void registerComponent(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  component)
Registers a component for tooltip management.

This will register key bindings to show and hide the tooltip text only if component has focus bindings. This is done so that components that are not normally focus traversable, such as JLabel, are not made focus traversable as a result of invoking this method.

Parameters:
component - a JComponent object to add
See Also:
Component.isFocusTraversable() sample code for java.awt.Component.isFocusTraversable() definition code for java.awt.Component.isFocusTraversable()

unregisterComponent sample code for javax.swing.ToolTipManager.unregisterComponent(javax.swing.JComponent) definition code for javax.swing.ToolTipManager.unregisterComponent(javax.swing.JComponent)

public void unregisterComponent(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  component)
Removes a component from tooltip control.

Parameters:
component - a JComponent object to remove

mouseEntered sample code for javax.swing.ToolTipManager.mouseEntered(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mouseEntered(java.awt.event.MouseEvent)

public void mouseEntered(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
Called when the mouse enters the region of a component. This determines whether the tool tip should be shown.

Specified by:
mouseEntered sample code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent) in interface MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener
Overrides:
mouseEntered sample code for java.awt.event.MouseAdapter.mouseEntered(java.awt.event.MouseEvent) definition code for java.awt.event.MouseAdapter.mouseEntered(java.awt.event.MouseEvent) in class MouseAdapter sample code for java.awt.event.MouseAdapter definition code for java.awt.event.MouseAdapter
Parameters:
event - the event in question

mouseExited sample code for javax.swing.ToolTipManager.mouseExited(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mouseExited(java.awt.event.MouseEvent)

public void mouseExited(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
Called when the mouse exits the region of a component. Any tool tip showing should be hidden.

Specified by:
mouseExited sample code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent) in interface MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener
Overrides:
mouseExited sample code for java.awt.event.MouseAdapter.mouseExited(java.awt.event.MouseEvent) definition code for java.awt.event.MouseAdapter.mouseExited(java.awt.event.MouseEvent) in class MouseAdapter sample code for java.awt.event.MouseAdapter definition code for java.awt.event.MouseAdapter
Parameters:
event - the event in question

mousePressed sample code for javax.swing.ToolTipManager.mousePressed(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mousePressed(java.awt.event.MouseEvent)

public void mousePressed(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
Called when the mouse is pressed. Any tool tip showing should be hidden.

Specified by:
mousePressed sample code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent) in interface MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener
Overrides:
mousePressed sample code for java.awt.event.MouseAdapter.mousePressed(java.awt.event.MouseEvent) definition code for java.awt.event.MouseAdapter.mousePressed(java.awt.event.MouseEvent) in class MouseAdapter sample code for java.awt.event.MouseAdapter definition code for java.awt.event.MouseAdapter
Parameters:
event - the event in question

mouseDragged sample code for javax.swing.ToolTipManager.mouseDragged(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mouseDragged(java.awt.event.MouseEvent)

public void mouseDragged(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
Called when the mouse is pressed and dragged. Does nothing.

Specified by:
mouseDragged sample code for java.awt.event.MouseMotionListener.mouseDragged(java.awt.event.MouseEvent) definition code for java.awt.event.MouseMotionListener.mouseDragged(java.awt.event.MouseEvent) in interface MouseMotionListener sample code for java.awt.event.MouseMotionListener definition code for java.awt.event.MouseMotionListener
Parameters:
event - the event in question

mouseMoved sample code for javax.swing.ToolTipManager.mouseMoved(java.awt.event.MouseEvent) definition code for javax.swing.ToolTipManager.mouseMoved(java.awt.event.MouseEvent)

public void mouseMoved(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  event)
Called when the mouse is moved. Determines whether the tool tip should be displayed.

Specified by:
mouseMoved sample code for java.awt.event.MouseMotionListener.mouseMoved(java.awt.event.MouseEvent) definition code for java.awt.event.MouseMotionListener.mouseMoved(java.awt.event.MouseEvent) in interface MouseMotionListener sample code for java.awt.event.MouseMotionListener definition code for java.awt.event.MouseMotionListener
Parameters:
event - the event in question