- java.lang.Object
-
- java.awt.event.MouseAdapter
-
- javax.swing.ToolTipManager
-
- All Implemented Interfaces:
- MouseListener, MouseMotionListener, MouseWheelListener, EventListener
public class ToolTipManager extends MouseAdapter implements MouseMotionListener
Manages all theToolTips
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. AfterdismissDelay
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 withinreshowDelay
milliseconds, the tooltip will immediately be shown, otherwise the tooltip will be shown again afterinitialDelay
milliseconds.- See Also:
JComponent.createToolTip()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected class
ToolTipManager.insideTimerAction
protected class
ToolTipManager.outsideTimerAction
protected class
ToolTipManager.stillInsideTimerAction
-
Field Summary
Fields Modifier and Type Field and Description protected boolean
heavyWeightPopupEnabled
protected boolean
lightWeightPopupEnabled
-
Method Summary
Methods Modifier and Type Method and Description int
getDismissDelay()
Returns the dismissal delay value.int
getInitialDelay()
Returns the initial delay value.int
getReshowDelay()
Returns the reshow delay property.boolean
isEnabled()
Returns true if this object is enabled.boolean
isLightWeightPopupEnabled()
Returns true if lightweight (all-Java)Tooltips
are in use, or false if heavyweight (native peer)Tooltips
are being used.void
mouseDragged(MouseEvent event)
Called when the mouse is pressed and dragged.void
mouseEntered(MouseEvent event)
Called when the mouse enters the region of a component.void
mouseExited(MouseEvent event)
Called when the mouse exits the region of a component.void
mouseMoved(MouseEvent event)
Called when the mouse is moved.void
mousePressed(MouseEvent event)
Called when the mouse is pressed.void
registerComponent(JComponent component)
Registers a component for tooltip management.void
setDismissDelay(int milliseconds)
Specifies the dismissal delay value.void
setEnabled(boolean flag)
Enables or disables the tooltip.void
setInitialDelay(int milliseconds)
Specifies the initial delay value.void
setLightWeightPopupEnabled(boolean aFlag)
When displaying theJToolTip
, theToolTipManager
chooses to use a lightweightJPanel
if it fits.void
setReshowDelay(int milliseconds)
Used to specify the amount of time before the user has to waitinitialDelay
milliseconds before a tooltip will be shown.static ToolTipManager
sharedInstance()
Returns a sharedToolTipManager
instance.void
unregisterComponent(JComponent component)
Removes a component from tooltip control.-
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseReleased, mouseWheelMoved
-
-
-
-
Field Detail
-
lightWeightPopupEnabled
protected boolean lightWeightPopupEnabled
-
heavyWeightPopupEnabled
protected boolean heavyWeightPopupEnabled
-
-
Method Detail
-
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
, theToolTipManager
chooses to use a lightweightJPanel
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
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
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()
-
getInitialDelay
public int getInitialDelay()
Returns the initial delay value.- Returns:
- an integer representing the initial delay value, in milliseconds
- See Also:
setInitialDelay(int)
-
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()
-
getDismissDelay
public int getDismissDelay()
Returns the dismissal delay value.- Returns:
- an integer representing the dismissal delay value, in milliseconds
- See Also:
setDismissDelay(int)
-
setReshowDelay
public void setReshowDelay(int milliseconds)
Used to specify the amount of time before the user has to waitinitialDelay
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 withinmilliseconds
milliseconds the tooltip will immediately be shown. Otherwise, if the user moves into a region with a valid tooltip aftermilliseconds
milliseconds, the user will have to wait an additionalinitialDelay
milliseconds before the tooltip is shown again.- Parameters:
milliseconds
- time in milliseconds- See Also:
getReshowDelay()
-
getReshowDelay
public int getReshowDelay()
Returns the reshow delay property.- Returns:
- reshown delay property
- See Also:
setReshowDelay(int)
-
sharedInstance
public static ToolTipManager sharedInstance()
Returns a sharedToolTipManager
instance.- Returns:
- a shared
ToolTipManager
object
-
registerComponent
public 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 asJLabel
, are not made focus traversable as a result of invoking this method.- Parameters:
component
- aJComponent
object to add- See Also:
Component.isFocusTraversable()
-
unregisterComponent
public void unregisterComponent(JComponent component)
Removes a component from tooltip control.- Parameters:
component
- aJComponent
object to remove
-
mouseEntered
public void mouseEntered(MouseEvent event)
Called when the mouse enters the region of a component. This determines whether the tool tip should be shown.- Specified by:
mouseEntered
in interfaceMouseListener
- Overrides:
mouseEntered
in classMouseAdapter
- Parameters:
event
- the event in question
-
mouseExited
public void mouseExited(MouseEvent event)
Called when the mouse exits the region of a component. Any tool tip showing should be hidden.- Specified by:
mouseExited
in interfaceMouseListener
- Overrides:
mouseExited
in classMouseAdapter
- Parameters:
event
- the event in question
-
mousePressed
public void mousePressed(MouseEvent event)
Called when the mouse is pressed. Any tool tip showing should be hidden.- Specified by:
mousePressed
in interfaceMouseListener
- Overrides:
mousePressed
in classMouseAdapter
- Parameters:
event
- the event in question
-
mouseDragged
public void mouseDragged(MouseEvent event)
Called when the mouse is pressed and dragged. Does nothing.- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classMouseAdapter
- Parameters:
event
- the event in question
-
mouseMoved
public void mouseMoved(MouseEvent event)
Called when the mouse is moved. Determines whether the tool tip should be displayed.- Specified by:
mouseMoved
in interfaceMouseMotionListener
- Overrides:
mouseMoved
in classMouseAdapter
- Parameters:
event
- the event in question
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/tooltipmanager.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.