Class ToolTipManager
- All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, EventListener
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.
- Since:
- 1.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classInside timer action.protected classOutside timer action.protected classStill inside timer action. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanHeavyweight popup enabled.protected booleanLightweight popup enabled. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the dismissal delay value.intReturns the initial delay value.intReturns the reshow delay property.booleanReturns true if this object is enabled.booleanReturns true if lightweight (all-Java)Tooltipsare in use, or false if heavyweight (native peer)Tooltipsare being used.voidmouseDragged(MouseEvent event) Called when the mouse is pressed and dragged.voidmouseEntered(MouseEvent event) Called when the mouse enters the region of a component.voidmouseExited(MouseEvent event) Called when the mouse exits the region of a component.voidmouseMoved(MouseEvent event) Called when the mouse is moved.voidmousePressed(MouseEvent event) Called when the mouse is pressed.voidregisterComponent(JComponent component) Registers a component for tooltip management.voidsetDismissDelay(int milliseconds) Specifies the dismissal delay value.voidsetEnabled(boolean flag) Enables or disables the tooltip.voidsetInitialDelay(int milliseconds) Specifies the initial delay value.voidsetLightWeightPopupEnabled(boolean aFlag) When displaying theJToolTip, theToolTipManagerchooses to use a lightweightJPanelif it fits.voidsetReshowDelay(int milliseconds) Used to specify the amount of time before the user has to waitinitialDelaymilliseconds before a tooltip will be shown.static ToolTipManagerReturns a sharedToolTipManagerinstance.voidunregisterComponent(JComponent component) Removes a component from tooltip control.Methods declared in class MouseAdapter
mouseClicked, mouseReleased, mouseWheelMovedModifier and TypeMethodDescriptionvoidInvoked when the mouse button has been clicked (pressed and released) on a component.voidInvoked when a mouse button has been released on a component.voidInvoked when the mouse wheel is rotated.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Field Details
-
lightWeightPopupEnabled
protected boolean lightWeightPopupEnabledLightweight popup enabled. -
heavyWeightPopupEnabled
protected boolean heavyWeightPopupEnabledHeavyweight popup enabled.
-
-
Method Details
-
setEnabled
public void setEnabled(boolean flag) Enables or disables the tooltip.- Parameters:
flag- true to enable the tip, false otherwise
-
isEnabled
public boolean isEnabled()Returns true if this object is enabled.- Returns:
- true if this object is enabled, false otherwise
-
setLightWeightPopupEnabled
public void setLightWeightPopupEnabled(boolean aFlag) When displaying theJToolTip, theToolTipManagerchooses to use a lightweightJPanelif 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
public boolean isLightWeightPopupEnabled()Returns true if lightweight (all-Java)Tooltipsare in use, or false if heavyweight (native peer)Tooltipsare being used.- Returns:
- true if lightweight
ToolTipsare in use
-
setInitialDelay
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
public int getInitialDelay()Returns the initial delay value.- Returns:
- an integer representing the initial delay value, in milliseconds
- See Also:
-
setDismissDelay
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
public int getDismissDelay()Returns the dismissal delay value.- Returns:
- an integer representing the dismissal delay value, in milliseconds
- See Also:
-
setReshowDelay
public void setReshowDelay(int milliseconds) Used to specify the amount of time before the user has to waitinitialDelaymilliseconds 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 withinmillisecondsmilliseconds the tooltip will immediately be shown. Otherwise, if the user moves into a region with a valid tooltip aftermillisecondsmilliseconds, the user will have to wait an additionalinitialDelaymilliseconds before the tooltip is shown again.- Parameters:
milliseconds- time in milliseconds- See Also:
-
getReshowDelay
public int getReshowDelay()Returns the reshow delay property.- Returns:
- reshow delay property
- See Also:
-
registerComponent
Registers a component for tooltip management.This will register key bindings to show and hide the tooltip text only if
componenthas focus bindings. This is done so that components that are not normally focus traversable, such asJLabel, are not made focus traversable as a result of invoking this method.- Parameters:
component- aJComponentobject to add- See Also:
-
unregisterComponent
Removes a component from tooltip control.- Parameters:
component- aJComponentobject to remove
-
mouseEntered
Called when the mouse enters the region of a component. This determines whether the tool tip should be shown.- Specified by:
mouseEnteredin interfaceMouseListener- Parameters:
event- the event in question
-
mouseExited
Called when the mouse exits the region of a component. Any tool tip showing should be hidden.- Specified by:
mouseExitedin interfaceMouseListener- Parameters:
event- the event in question
-
mousePressed
Called when the mouse is pressed. Any tool tip showing should be hidden.- Specified by:
mousePressedin interfaceMouseListener- Parameters:
event- the event in question
-
mouseDragged
Called when the mouse is pressed and dragged. Does nothing.- Specified by:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin classMouseAdapter- Parameters:
event- the event in question
-
mouseMoved
Called when the mouse is moved. Determines whether the tool tip should be displayed.- Specified by:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classMouseAdapter- Parameters:
event- the event in question
-