text property is modified
to show plain text to the user. However, a Tooltip is able to show within it
an arbitrary scenegraph of nodes - this is done by creating the scenegraph
and setting it inside the Tooltip graphic
property.
You use the following approach to set a Tooltip on any node:
Rectangle rect = new Rectangle(0, 0, 100, 100);
Tooltip t = new Tooltip("A Square");
Tooltip.install(rect, t);
This tooltip will then participate with the typical tooltip semantics (i.e.
appearing on hover, etc). Note that the Tooltip does not have to be
uninstalled: it will be garbage collected when it is not referenced by any
Node. It is possible to manually uninstall the tooltip, however.
A single tooltip can be installed on multiple target nodes or multiple controls.
Because most Tooltips are shown on UI controls, there is special API for all controls to make installing a Tooltip less verbose. The example below shows how to create a tooltip for a Button control:
Button button = new Button("Hover Over Me");
button.setTooltip(new Tooltip("Tooltip for Button"));
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ReadOnlyBooleanWrapper | activated
Typically, the tooltip is "activated" when the mouse moves over a Control. |
| private static Tooltip. | |
| private static final CssMetaData | |
| private final ObjectProperty | |
| private final ObjectProperty | |
| private static final CssMetaData | |
| private final ObjectProperty | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private final DoubleProperty | |
| private static final CssMetaData | |
| private final ObjectProperty | |
| private StyleableStringProperty | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private final ObjectProperty | |
| private final ObjectProperty | |
| private static final List | |
| private final StringProperty | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private final ObjectProperty | |
| private final ObjectProperty | |
| private static String | |
| private static int | |
| private static int | |
| private static final CssMetaData | |
| private final BooleanProperty |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final ReadOnlyBooleanProperty | |
| public final ObjectProperty | Returns: the content display propertySpecifies the positioning of the graphic relative to the text. |
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public final ObjectProperty | |
| public static List | Returns: theCssMetaDataHides javafx. Gets the |
| public final ContentDisplay | |
| public List | getCssMetaData()
Overrides javafx. Implements javafx. The CssMetaData of this Styleable. |
| public final Font | |
| public final Node | |
| public final double | |
| public final Duration | |
| public final Duration | |
| public final Duration | |
| public Styleable | getStyleableParent()
Overrides javafx. Implements javafx. Return the parent of this Styleable, or null if there is no parent. |
| public final String | |
| public final TextAlignment | |
| public final OverrunStyle | |
| public final ObjectProperty | |
| public final DoubleProperty | Returns: the graphic text gap propertyThe amount of space between the graphic and text |
| public final ObjectProperty | Returns: the hide delay propertyThe duration in which to continue showing the tooltip after the mouse has left the node. |
| private StyleableStringProperty | |
| public static void | |
| public final boolean | |
| public final boolean | |
| pack-priv final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final ObjectProperty | Returns: show delay propertyThe delay between the mouse entering the hovered node and when the associated tooltip will be shown to the user. |
| public final ObjectProperty | Returns: the show duration propertyThe duration that the tooltip should remain showing for until it is no longer visible to the user. |
| public final ObjectProperty | Returns: the text alignment propertySpecifies the behavior for lines of text when text is multiline. |
| public final ObjectProperty | Returns: the text overrun propertySpecifies the behavior to use if the text of the |
| public final StringProperty | |
| public static void | |
| public final BooleanProperty | Returns: the wrap text propertyIf a run of text exceeds the width of the Tooltip, then this variable indicates whether the text should wrap onto another line. |
| activated | back to summary |
|---|---|
| private final ReadOnlyBooleanWrapper activated Typically, the tooltip is "activated" when the mouse moves over a Control. There is usually some delay between when the Tooltip becomes "activated" and when it is actually shown. The details (such as the amount of delay, etc) is left to the Skin implementation. | |
| BEHAVIOR | back to summary |
|---|---|
| private static Tooltip. | |
| CONTENT_DISPLAY | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| contentDisplay | back to summary |
|---|---|
| private final ObjectProperty<ContentDisplay> contentDisplay | |
| font | back to summary |
|---|---|
| private final ObjectProperty<Font> font | |
| FONT | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| graphic | back to summary |
|---|---|
| private final ObjectProperty<Node> graphic | |
| GRAPHIC | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| GRAPHIC_TEXT_GAP | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| graphicTextGap | back to summary |
|---|---|
| private final DoubleProperty graphicTextGap | |
| HIDE_DELAY | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| hideDelayProperty | back to summary |
|---|---|
| private final ObjectProperty<Duration> hideDelayProperty | |
| imageUrl | back to summary |
|---|---|
| private StyleableStringProperty imageUrl | |
| SHOW_DELAY | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| SHOW_DURATION | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| showDelayProperty | back to summary |
|---|---|
| private final ObjectProperty<Duration> showDelayProperty | |
| showDurationProperty | back to summary |
|---|---|
| private final ObjectProperty<Duration> showDurationProperty | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| text | back to summary |
|---|---|
| private final StringProperty text | |
| TEXT_ALIGNMENT | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| TEXT_OVERRUN | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| textAlignment | back to summary |
|---|---|
| private final ObjectProperty<TextAlignment> textAlignment | |
| textOverrun | back to summary |
|---|---|
| private final ObjectProperty<OverrunStyle> textOverrun | |
| TOOLTIP_PROP_KEY | back to summary |
|---|---|
| private static String TOOLTIP_PROP_KEY | |
| TOOLTIP_XOFFSET | back to summary |
|---|---|
| private static int TOOLTIP_XOFFSET | |
| TOOLTIP_YOFFSET | back to summary |
|---|---|
| private static int TOOLTIP_YOFFSET | |
| WRAP_TEXT | back to summary |
|---|---|
| private static final CssMetaData<Tooltip. | |
| wrapText | back to summary |
|---|---|
| private final BooleanProperty wrapText | |
| Tooltip | back to summary |
|---|---|
| public Tooltip() Creates a tooltip with an empty string for its text. | |
| Tooltip | back to summary |
|---|---|
| public Tooltip(String text) Creates a tooltip with the specified text.
| |
| activatedProperty | back to summary |
|---|---|
| public final ReadOnlyBooleanProperty activatedProperty() | |
| contentDisplayProperty | back to summary |
|---|---|
| public final ObjectProperty Specifies the positioning of the graphic relative to the text.
| |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. Create a new instance of the default skin for this control. This is called to create a skin for the control if
no skin is provided via CSS
| |
| fontProperty | back to summary |
|---|---|
| public final ObjectProperty The default font to use for text in the Tooltip. If the Tooltip's text is rich text then this font may or may not be used depending on the font information embedded in the rich text, but in any case where a default font is required, this font will be used.
| |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Gets the
| |
| getContentDisplay | back to summary |
|---|---|
| public final ContentDisplay getContentDisplay() | |
| getCssMetaData | back to summary |
|---|---|
| public List Overrides javafx. Implements javafx. Doc from javafx. The CssMetaData of this Styleable. This may be returned as an unmodifiable list.
| |
| getFont | back to summary |
|---|---|
| public final Font getFont() | |
| getGraphic | back to summary |
|---|---|
| public final Node getGraphic() | |
| getGraphicTextGap | back to summary |
|---|---|
| public final double getGraphicTextGap() | |
| getHideDelay | back to summary |
|---|---|
| public final Duration getHideDelay() | |
| getShowDelay | back to summary |
|---|---|
| public final Duration getShowDelay() | |
| getShowDuration | back to summary |
|---|---|
| public final Duration getShowDuration() | |
| getStyleableParent | back to summary |
|---|---|
| public Styleable getStyleableParent() Overrides javafx. Implements javafx. Doc from javafx. Return the parent of this Styleable, or null if there is no parent.
A PopupControl's styles are based on the popup "owner" which is the
| |
| getText | back to summary |
|---|---|
| public final String getText() | |
| getTextAlignment | back to summary |
|---|---|
| public final TextAlignment getTextAlignment() | |
| getTextOverrun | back to summary |
|---|---|
| public final OverrunStyle getTextOverrun() | |
| graphicProperty | back to summary |
|---|---|
| public final ObjectProperty An optional icon for the Tooltip. This can be positioned relative to the
text by using the
| |
| graphicTextGapProperty | back to summary |
|---|---|
| public final DoubleProperty graphicTextGapProperty() The amount of space between the graphic and text
| |
| hideDelayProperty | back to summary |
|---|---|
| public final ObjectProperty The duration in which to continue showing the tooltip after the mouse has left the node. Once this time has elapsed the tooltip will hide. The default value is 200ms.
| |
| imageUrlProperty | back to summary |
|---|---|
| private StyleableStringProperty imageUrlProperty() | |
| install | back to summary |
|---|---|
| public static void install(Node node, Tooltip t) Associates the given | |
| isActivated | back to summary |
|---|---|
| public final boolean isActivated() | |
| isWrapText | back to summary |
|---|---|
| public final boolean isWrapText() | |
| setActivated | back to summary |
|---|---|
| pack-priv final void setActivated(boolean value) | |
| setContentDisplay | back to summary |
|---|---|
| public final void setContentDisplay(ContentDisplay value) | |
| setFont | back to summary |
|---|---|
| public final void setFont(Font value) | |
| setGraphic | back to summary |
|---|---|
| public final void setGraphic(Node value) | |
| setGraphicTextGap | back to summary |
|---|---|
| public final void setGraphicTextGap(double value) | |
| setHideDelay | back to summary |
|---|---|
| public final void setHideDelay(Duration hideDelay) | |
| setShowDelay | back to summary |
|---|---|
| public final void setShowDelay(Duration showDelay) | |
| setShowDuration | back to summary |
|---|---|
| public final void setShowDuration(Duration showDuration) | |
| setText | back to summary |
|---|---|
| public final void setText(String value) | |
| setTextAlignment | back to summary |
|---|---|
| public final void setTextAlignment(TextAlignment value) | |
| setTextOverrun | back to summary |
|---|---|
| public final void setTextOverrun(OverrunStyle value) | |
| setWrapText | back to summary |
|---|---|
| public final void setWrapText(boolean value) | |
| showDelayProperty | back to summary |
|---|---|
| public final ObjectProperty The delay between the mouse entering the hovered node and when the associated tooltip will be shown to the user. The default delay is 1000ms.
| |
| showDurationProperty | back to summary |
|---|---|
| public final ObjectProperty The duration that the tooltip should remain showing for until it is no longer visible to the user.
If the mouse leaves the control before the showDuration finishes, then the tooltip will remain showing
for the duration specified in the
| |
| textAlignmentProperty | back to summary |
|---|---|
| public final ObjectProperty Specifies the behavior for lines of text when text is multiline.
Unlike
| |
| textOverrunProperty | back to summary |
|---|---|
| public final ObjectProperty Specifies the behavior to use if the text of the
| |
| textProperty | back to summary |
|---|---|
| public final StringProperty textProperty() The text to display in the tooltip. If the text is set to null, an empty string will be displayed, despite the value being null.
| |
| uninstall | back to summary |
|---|---|
| public static void uninstall(Node node, Tooltip t) Removes the association of the given | |
| wrapTextProperty | back to summary |
|---|---|
| public final BooleanProperty wrapTextProperty() If a run of text exceeds the width of the Tooltip, then this variable indicates whether the text should wrap onto another line.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| tooltip | back to summary |
|---|---|
| private Tooltip tooltip | |
| CSSBridge | back to summary |
|---|---|
| pack-priv CSSBridge() | |
| Modifier and Type | Field and Description |
|---|---|
| private Tooltip | activatedTooltip
The tooltip that is currently activated. |
| private Timeline | |
| private boolean | |
| private Timeline | |
| private Node | hoveredNode
The Node with a tooltip over which the mouse is hovering. |
| private EventHandler | KILL_HANDLER
Registers for mouse click, press, release, drag events. |
| private double | lastMouseX
The last position of the mouse, in screen coordinates. |
| private double | |
| private EventHandler | LEAVING_HANDLER
Registers for mouse exit events. |
| private Timeline | |
| private EventHandler | MOVE_HANDLER
Registers for mouse move events only. |
| private Tooltip | visibleTooltip
The tooltip that is currently visible. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private Window | |
| private void | |
| private boolean | Returns: true if entire hierarchy is visiblethe node to check node)Gets whether the entire window hierarchy is visible for this node. |
| private void |
| activatedTooltip | back to summary |
|---|---|
| private Tooltip activatedTooltip The tooltip that is currently activated. There can only be one of these at a time. | |
| activationTimer | back to summary |
|---|---|
| private Timeline activationTimer | |
| hideOnExit | back to summary |
|---|---|
| private boolean hideOnExit | |
| hideTimer | back to summary |
|---|---|
| private Timeline hideTimer | |
| hoveredNode | back to summary |
|---|---|
| private Node hoveredNode The Node with a tooltip over which the mouse is hovering. There can only be one of these at a time. | |
| KILL_HANDLER | back to summary |
|---|---|
| private EventHandler<MouseEvent> KILL_HANDLER Registers for mouse click, press, release, drag events. If any of these occur, then the tooltip is hidden (if it is visible), it is deactivated, and any and all timers are stopped. | |
| lastMouseX | back to summary |
|---|---|
| private double lastMouseX The last position of the mouse, in screen coordinates. | |
| lastMouseY | back to summary |
|---|---|
| private double lastMouseY | |
| LEAVING_HANDLER | back to summary |
|---|---|
| private EventHandler<MouseEvent> LEAVING_HANDLER Registers for mouse exit events. If the ACTIVATION_TIMER is running then this will simply stop it. If the HIDE_TIMER is running then this will stop the HIDE_TIMER, hide the tooltip, and start the LEFT_TIMER. | |
| leftTimer | back to summary |
|---|---|
| private Timeline leftTimer | |
| MOVE_HANDLER | back to summary |
|---|---|
| private EventHandler<MouseEvent> MOVE_HANDLER Registers for mouse move events only. When the mouse is moved, this handler will detect it and decide whether to start the ACTIVATION_TIMER (if the ACTIVATION_TIMER is not started), restart the ACTIVATION_TIMER (if ACTIVATION_TIMER is running), or skip the ACTIVATION_TIMER and just show the tooltip (if the LEFT_TIMER is running). | |
| visibleTooltip | back to summary |
|---|---|
| private Tooltip visibleTooltip The tooltip that is currently visible. There can only be one of these at a time. | |
| TooltipBehavior | back to summary |
|---|---|
| pack-priv TooltipBehavior(final boolean hideOnExit) | |
| getWindow | back to summary |
|---|---|
| private Window getWindow(final Node node) Gets the top level window associated with this node. | |
| install | back to summary |
|---|---|
| private void install(Node node, Tooltip t) | |
| isWindowHierarchyVisible | back to summary |
|---|---|
| private boolean isWindowHierarchyVisible(Node node) Gets whether the entire window hierarchy is visible for this node.
| |
| uninstall | back to summary |
|---|---|
| private void uninstall(Node node) | |