public class Tooltip extends PopupControl
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:
import javafx.scene.control.Tooltip; import javafx.scene.control.Button; Button button = new Button("Hover Over Me"); button.setTooltip(new Tooltip("Tooltip for Button"));
Type | Property and Description |
---|---|
ReadOnlyBooleanProperty |
activated
Typically, the tooltip is "activated" when the mouse moves over a Control.
|
<any> |
contentDisplay
Specifies the positioning of the graphic relative to the text.
|
<any> |
font
The default font to use for text in the Tooltip.
|
<any> |
graphic
An optional icon for the Tooltip.
|
DoubleProperty |
graphicTextGap
The amount of space between the graphic and text
|
<any> |
hideDelay
The duration in which to continue showing the tooltip after the mouse has left the node.
|
private StyleableStringProperty |
imageUrl |
<any> |
showDelay
The delay between the mouse entering the hovered node and when the associated tooltip will be shown to the user.
|
<any> |
showDuration
The duration that the tooltip should remain showing for until it is no longer visible to the user.
|
<any> |
textAlignment
Specifies the behavior for lines of text when text is multiline.
|
<any> |
textOverrun
Specifies the behavior to use if the text of the
Tooltip
exceeds the available space for rendering the text. |
StringProperty |
text
The text to display in the tooltip.
|
BooleanProperty |
wrapText
If a run of text exceeds the width of the Tooltip, then this variable
indicates whether the text should wrap onto another line.
|
idProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, prefHeightProperty, prefWidthProperty, skinProperty, styleProperty
Modifier and Type | Class and Description |
---|---|
private class |
Tooltip.CSSBridge
*
Support classes *
*
|
private static class |
Tooltip.TooltipBehavior |
PopupControl.CSSBridgeHelper
Modifier and Type | Field and Description |
---|---|
private ReadOnlyBooleanWrapper |
activated
Typically, the tooltip is "activated" when the mouse moves over a Control.
|
private static Tooltip.TooltipBehavior |
BEHAVIOR |
private static <any> |
CONTENT_DISPLAY |
private <any> |
contentDisplay |
private <any> |
font |
private static <any> |
FONT
*
Stylesheet Handling *
*
|
private <any> |
graphic |
private static <any> |
GRAPHIC |
private static <any> |
GRAPHIC_TEXT_GAP |
private DoubleProperty |
graphicTextGap |
private static <any> |
HIDE_DELAY |
private <any> |
hideDelayProperty |
private StyleableStringProperty |
imageUrl |
private static <any> |
SHOW_DELAY |
private static <any> |
SHOW_DURATION |
private <any> |
showDelayProperty |
private <any> |
showDurationProperty |
private static java.util.List<<any>> |
STYLEABLES |
private StringProperty |
text |
private static <any> |
TEXT_ALIGNMENT |
private static <any> |
TEXT_OVERRUN |
private <any> |
textAlignment |
private <any> |
textOverrun |
private static java.lang.String |
TOOLTIP_PROP_KEY |
private static int |
TOOLTIP_XOFFSET |
private static int |
TOOLTIP_YOFFSET |
private static <any> |
WRAP_TEXT |
private BooleanProperty |
wrapText |
bridge, USE_COMPUTED_SIZE, USE_PREF_SIZE
Constructor and Description |
---|
Tooltip()
Creates a tooltip with an empty string for its text.
|
Tooltip(java.lang.String text)
Creates a tooltip with the specified text.
|
Modifier and Type | Method and Description |
---|---|
ReadOnlyBooleanProperty |
activatedProperty()
Typically, the tooltip is "activated" when the mouse moves over a Control.
|
<any> |
contentDisplayProperty()
Specifies the positioning of the graphic relative to the text.
|
protected Skin<?> |
createDefaultSkin()
Create a new instance of the default skin for this control.
|
<any> |
fontProperty()
The default font to use for text in the Tooltip.
|
static java.util.List<<any>> |
getClassCssMetaData() |
ContentDisplay |
getContentDisplay()
Gets the value of the property contentDisplay.
|
java.util.List<<any>> |
getCssMetaData() |
Font |
getFont()
Gets the value of the property font.
|
Node |
getGraphic()
Gets the value of the property graphic.
|
double |
getGraphicTextGap()
Gets the value of the property graphicTextGap.
|
Duration |
getHideDelay()
Gets the value of the property hideDelay.
|
Duration |
getShowDelay()
Gets the value of the property showDelay.
|
Duration |
getShowDuration()
Gets the value of the property showDuration.
|
Styleable |
getStyleableParent()
A PopupControl's styles are based on the popup "owner" which is the
ownerNode or,
if the ownerNode is not set, the root of the
ownerWindow's
scene. |
java.lang.String |
getText()
Gets the value of the property text.
|
TextAlignment |
getTextAlignment()
Gets the value of the property textAlignment.
|
OverrunStyle |
getTextOverrun()
Gets the value of the property textOverrun.
|
<any> |
graphicProperty()
An optional icon for the Tooltip.
|
DoubleProperty |
graphicTextGapProperty()
The amount of space between the graphic and text
|
<any> |
hideDelayProperty()
The duration in which to continue showing the tooltip after the mouse has left the node.
|
private StyleableStringProperty |
imageUrlProperty() |
static void |
install(Node node,
Tooltip t)
Associates the given
Tooltip with the given Node . |
boolean |
isActivated()
Gets the value of the property activated.
|
boolean |
isWrapText()
Gets the value of the property wrapText.
|
(package private) void |
setActivated(boolean value) |
void |
setContentDisplay(ContentDisplay value)
Sets the value of the property contentDisplay.
|
void |
setFont(Font value)
Sets the value of the property font.
|
void |
setGraphic(Node value)
Sets the value of the property graphic.
|
void |
setGraphicTextGap(double value)
Sets the value of the property graphicTextGap.
|
void |
setHideDelay(Duration hideDelay)
Sets the value of the property hideDelay.
|
void |
setShowDelay(Duration showDelay)
Sets the value of the property showDelay.
|
void |
setShowDuration(Duration showDuration)
Sets the value of the property showDuration.
|
void |
setText(java.lang.String value)
Sets the value of the property text.
|
void |
setTextAlignment(TextAlignment value)
Sets the value of the property textAlignment.
|
void |
setTextOverrun(OverrunStyle value)
Sets the value of the property textOverrun.
|
void |
setWrapText(boolean value)
Sets the value of the property wrapText.
|
<any> |
showDelayProperty()
The delay between the mouse entering the hovered node and when the associated tooltip will be shown to the user.
|
<any> |
showDurationProperty()
The duration that the tooltip should remain showing for until it is no longer visible to the user.
|
<any> |
textAlignmentProperty()
Specifies the behavior for lines of text when text is multiline.
|
<any> |
textOverrunProperty()
Specifies the behavior to use if the text of the
Tooltip
exceeds the available space for rendering the text. |
StringProperty |
textProperty()
The text to display in the tooltip.
|
static void |
uninstall(Node node,
Tooltip t)
Removes the association of the given
Tooltip on the specified
Node . |
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.
|
getId, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, getPseudoClassStates, getSkin, getStyle, getStyleableNode, getStyleClass, getTypeSelector, idProperty, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, pseudoClassStateChanged, setId, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setPrefHeight, setPrefSize, setPrefWidth, setSkin, setStyle, skinProperty, styleProperty
public final StringProperty textProperty
getText()
,
setText(String)
public final <any> textAlignmentProperty
contentDisplay
which affects the
graphic and text, this setting only affects multiple lines of text
relative to the text bounds.public final <any> textOverrunProperty
Tooltip
exceeds the available space for rendering the text.getTextOverrun()
,
setTextOverrun(OverrunStyle)
public final BooleanProperty wrapTextProperty
isWrapText()
,
setWrapText(boolean)
public final <any> fontProperty
getFont()
,
setFont(Font)
public final <any> showDelayProperty
getShowDelay()
,
setShowDelay(Duration)
public final <any> showDurationProperty
hideDelayProperty()
, even if the remaining time of the showDuration
is less than the hideDelay duration. The default value is 5000ms.getShowDuration()
,
setShowDuration(Duration)
public final <any> hideDelayProperty
getHideDelay()
,
setHideDelay(Duration)
public final <any> graphicProperty
content display
property.
The node specified for this variable cannot appear elsewhere in the
scene graph, otherwise the IllegalArgumentException
is thrown.
See the class description of Node
for more detail.getGraphic()
,
setGraphic(Node)
private StyleableStringProperty imageUrlProperty
public final <any> contentDisplayProperty
public final DoubleProperty graphicTextGapProperty
getGraphicTextGap()
,
setGraphicTextGap(double)
public final ReadOnlyBooleanProperty activatedProperty
isActivated()
private static java.lang.String TOOLTIP_PROP_KEY
private static int TOOLTIP_XOFFSET
private static int TOOLTIP_YOFFSET
private static Tooltip.TooltipBehavior BEHAVIOR
private final StringProperty text
private final <any> textAlignment
private final <any> textOverrun
private final BooleanProperty wrapText
private final <any> font
private final <any> showDelayProperty
private final <any> showDurationProperty
private final <any> hideDelayProperty
private final <any> graphic
private StyleableStringProperty imageUrl
private final <any> contentDisplay
private final DoubleProperty graphicTextGap
private final ReadOnlyBooleanWrapper activated
private static final <any> FONT
private static final <any> TEXT_ALIGNMENT
private static final <any> TEXT_OVERRUN
private static final <any> WRAP_TEXT
private static final <any> GRAPHIC
private static final <any> CONTENT_DISPLAY
private static final <any> GRAPHIC_TEXT_GAP
private static final <any> SHOW_DELAY
private static final <any> SHOW_DURATION
private static final <any> HIDE_DELAY
private static final java.util.List<<any>> STYLEABLES
public Tooltip()
public Tooltip(java.lang.String text)
text
- A text string for the tooltip.public static void install(Node node, Tooltip t)
Tooltip
with the given Node
. The tooltip
can then behave similar to when it is set on any Control
. A single
tooltip can be associated with multiple nodes.node
- the nodet
- the tooltipTooltip
public static void uninstall(Node node, Tooltip t)
Tooltip
on the specified
Node
. Hence hovering on the node will no longer result in showing of the
tooltip.node
- the nodet
- the tooltipTooltip
public final StringProperty textProperty()
getText()
,
setText(String)
public final void setText(java.lang.String value)
public final java.lang.String getText()
public final <any> textAlignmentProperty()
contentDisplay
which affects the
graphic and text, this setting only affects multiple lines of text
relative to the text bounds.public final void setTextAlignment(TextAlignment value)
public final TextAlignment getTextAlignment()
public final <any> textOverrunProperty()
Tooltip
exceeds the available space for rendering the text.getTextOverrun()
,
setTextOverrun(OverrunStyle)
public final void setTextOverrun(OverrunStyle value)
public final OverrunStyle getTextOverrun()
public final BooleanProperty wrapTextProperty()
isWrapText()
,
setWrapText(boolean)
public final void setWrapText(boolean value)
public final boolean isWrapText()
public final <any> fontProperty()
getFont()
,
setFont(Font)
public final void setFont(Font value)
public final Font getFont()
public final <any> showDelayProperty()
getShowDelay()
,
setShowDelay(Duration)
public final void setShowDelay(Duration showDelay)
public final Duration getShowDelay()
public final <any> showDurationProperty()
hideDelayProperty()
, even if the remaining time of the showDuration
is less than the hideDelay duration. The default value is 5000ms.getShowDuration()
,
setShowDuration(Duration)
public final void setShowDuration(Duration showDuration)
public final Duration getShowDuration()
public final <any> hideDelayProperty()
getHideDelay()
,
setHideDelay(Duration)
public final void setHideDelay(Duration hideDelay)
public final Duration getHideDelay()
public final <any> graphicProperty()
content display
property.
The node specified for this variable cannot appear elsewhere in the
scene graph, otherwise the IllegalArgumentException
is thrown.
See the class description of Node
for more detail.getGraphic()
,
setGraphic(Node)
public final void setGraphic(Node value)
public final Node getGraphic()
private StyleableStringProperty imageUrlProperty()
public final <any> contentDisplayProperty()
public final void setContentDisplay(ContentDisplay value)
public final ContentDisplay getContentDisplay()
public final DoubleProperty graphicTextGapProperty()
getGraphicTextGap()
,
setGraphicTextGap(double)
public final void setGraphicTextGap(double value)
public final double getGraphicTextGap()
final void setActivated(boolean value)
public final boolean isActivated()
public final ReadOnlyBooleanProperty activatedProperty()
isActivated()
protected Skin<?> createDefaultSkin()
-fx-skin
or set explicitly in a sub-class with setSkin(...)
.createDefaultSkin
in class PopupControl
public static java.util.List<<any>> getClassCssMetaData()
public java.util.List<<any>> getCssMetaData()
getCssMetaData
in class PopupControl
public Styleable getStyleableParent()
PopupControl
ownerNode
or,
if the ownerNode is not set, the root of the
ownerWindow's
scene. If the popup has not been shown, both ownerNode and ownerWindow will be null and null
will be returned.
Note that the PopupWindow's scene root is not returned because
there is no way to guarantee that the PopupWindow's scene root would
properly return the ownerNode or ownerWindow.getStyleableParent
in class PopupControl
javafx.stage.PopupWindow#getOwnerNode()
, javafx.stage.PopupWindow#getOwnerWindow()
,
or null.