public class ToolTipManager extends MouseAdapter implements 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 visible 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.
JComponent.createToolTip()
Modifier and Type | Class and Description |
---|---|
protected class |
ToolTipManager.insideTimerAction |
protected class |
ToolTipManager.outsideTimerAction |
protected class |
ToolTipManager.stillInsideTimerAction |
protected boolean lightWeightPopupEnabled
protected boolean heavyWeightPopupEnabled
public void setEnabled(boolean flag)
Enables or disables the tooltip.
flag
- true to enable the tip, false otherwisepublic boolean isEnabled()
Returns true if this object is enabled.
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.
aFlag
- true if a lightweight panel is desired, false otherwisepublic boolean isLightWeightPopupEnabled()
Returns true if lightweight (all-Java) Tooltips
are in use, or false if heavyweight (native peer) Tooltips
are being used.
ToolTips
are in usepublic void setInitialDelay(int milliseconds)
Specifies the initial delay value.
milliseconds
- the number of milliseconds to delay (after the cursor has paused) before displaying the tooltipgetInitialDelay()
public int getInitialDelay()
Returns the initial delay value.
setInitialDelay(int)
public void setDismissDelay(int milliseconds)
Specifies the dismissal delay value.
milliseconds
- the number of milliseconds to delay before taking away the tooltipgetDismissDelay()
public int getDismissDelay()
Returns the dismissal delay value.
setDismissDelay(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.
milliseconds
- time in millisecondsgetReshowDelay()
public int getReshowDelay()
Returns the reshow delay property.
setReshowDelay(int)
public static ToolTipManager sharedInstance()
Returns a shared ToolTipManager
instance.
ToolTipManager
objectpublic void registerComponent(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.
component
- a JComponent
object to addComponent.isFocusTraversable()
public void unregisterComponent(JComponent component)
Removes a component from tooltip control.
component
- a JComponent
object to removepublic void mouseEntered(MouseEvent event)
Called when the mouse enters the region of a component. This determines whether the tool tip should be shown.
mouseEntered
in interface MouseListener
mouseEntered
in class MouseAdapter
event
- the event in questionpublic void mouseExited(MouseEvent event)
Called when the mouse exits the region of a component. Any tool tip showing should be hidden.
mouseExited
in interface MouseListener
mouseExited
in class MouseAdapter
event
- the event in questionpublic void mousePressed(MouseEvent event)
Called when the mouse is pressed. Any tool tip showing should be hidden.
mousePressed
in interface MouseListener
mousePressed
in class MouseAdapter
event
- the event in questionpublic void mouseDragged(MouseEvent event)
Called when the mouse is pressed and dragged. Does nothing.
mouseDragged
in interface MouseMotionListener
mouseDragged
in class MouseAdapter
event
- the event in questionpublic void mouseMoved(MouseEvent event)
Called when the mouse is moved. Determines whether the tool tip should be displayed.
mouseMoved
in interface MouseMotionListener
mouseMoved
in class MouseAdapter
event
- the event in question
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.