Java Reference
In-Depth Information
ToolTipManager Properties
Once you have accessed the shared instance of ToolTipManager , you can customize when and
if tooltip text appears. As Table 4-7 shows, there are five configurable properties.
Table 4-7. ToolTipManager Properties
Property Name
Data Type
Access
dismissDelay
int
Read-write
enabled
boolean
Read-write
initialDelay
int
Read-write
lightWeightPopupEnabled
boolean
Read-write
reshowDelay
int
Read-only
Initially, tooltips are enabled, but you can disable them with ToolTipManager.
sharedInstance().setEnabled(false) . This allows you to always associate tooltips with
components, while letting the end user enable and disable them when desired.
There are three timing-oriented properties: initialDelay , dismissDelay , and reshowDelay .
They all measure time in milliseconds. The initialDelay property is the number of milliseconds
the user must rest the mouse inside the component before the appropriate tooltip text appears.
The dismissDelay specifies the length of time the text appears while the mouse remains
motionless; if the user moves the mouse, it also causes the text to disappear. The reshowDelay
determines how long a user must remain outside a component before reentry would cause the
pop-up text to reappear.
The lightWeightPopupEnabled property is used to determine the pop-up window type to
hold the tooltip text. If the property is true and the pop-up text fits entirely within the bounds
of the top-level window, the text appears within a Swing JPanel . If this property is false and the
pop-up text fits entirely within the bounds of the top-level window, the text appears within an
AWT Panel . If part of the text wouldn't appear within the top-level window no matter what the
property setting is, the pop-up text would appear within a Window .
Although not properties of ToolTipManager , two other methods of ToolTipManager are
worth mentioning:
public void registerComponent(JComponent component)
public void unregisterComponent(JComponent component)
When you call the setToolTipText() method of JComponent , this causes the component to
register itself with the ToolTipManager . There are times, however, when you need to register
a component directly. This is necessary when the display of part of a component is left to
another renderer. With JTree , for instance, a TreeCellRenderer displays each node of the tree.
When the renderer displays the tooltip text, you “register” the JTree and tell the renderer what
text to display.
 
Search WWH ::




Custom Search