@DefaultProperty(value="text") public abstract class Labeled extends Control
Control
is one which has as part of its user interface
a textual content associated with it. For example, a Button
displays
text
, as does a Label
, a Tooltip
, and many
other controls.
Labeled is also a convenient base class from which to extend when building new Controls which, as part of their UI, display read-only textual content.
Example of how to place a graphic above the text:
Image image = new Image(getClass().getResourceAsStream("image.png"));
ImageView imageView = new ImageView();
imageView.setImage(image);
Label label = new Label("text", imageView);
label.setContentDisplay(ContentDisplay.TOP);
Button
,
Label
,
ToggleButton
Type | Property and Description |
---|---|
ObjectProperty<Pos> |
alignment
Specifies how the text and graphic within the Labeled should be
aligned when there is empty space within the Labeled.
|
ObjectProperty<ContentDisplay> |
contentDisplay
Specifies the positioning of the graphic relative to the text.
|
StringProperty |
ellipsisString
Specifies the string to display for the ellipsis when text is truncated.
|
ObjectProperty<Font> |
font
The default font to use for text in the Labeled.
|
ObjectProperty<Node> |
graphic
An optional icon for the Labeled.
|
DoubleProperty |
graphicTextGap
The amount of space between the graphic and text
|
ReadOnlyObjectProperty<Insets> |
labelPadding
The padding around the Labeled's text and graphic content.
|
DoubleProperty |
lineSpacing
Specifies the space in pixel between lines.
|
BooleanProperty |
mnemonicParsing
MnemonicParsing property to enable/disable text parsing.
|
ObjectProperty<TextAlignment> |
textAlignment
Specifies the behavior for lines of text when text is multiline
Unlike
contentDisplayProperty() which affects the graphic and text, this setting
only affects multiple lines of text relative to the text bounds. |
ObjectProperty<Paint> |
textFill
The
Paint used to fill the text. |
ObjectProperty<OverrunStyle> |
textOverrun
Specifies the behavior to use if the text of the
Labeled
exceeds the available space for rendering the text. |
StringProperty |
text
The text to display in the label.
|
BooleanProperty |
underline
Whether all text should be underlined.
|
BooleanProperty |
wrapText
If a run of text exceeds the width of the Labeled, then this variable
indicates whether the text should wrap onto another line.
|
contextMenu, skin, tooltip
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
needsLayout
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, visible
USE_COMPUTED_SIZE, USE_PREF_SIZE
BASELINE_OFFSET_SAME_AS_HEIGHT
Constructor and Description |
---|
Labeled()
Creates a Label with no text and graphic
|
Labeled(String text)
Creates a Label with text
|
Labeled(String text,
Node graphic)
Creates a Label with text and a graphic
|
Modifier and Type | Method and Description |
---|---|
ObjectProperty<Pos> |
alignmentProperty()
Specifies how the text and graphic within the Labeled should be
aligned when there is empty space within the Labeled.
|
ObjectProperty<ContentDisplay> |
contentDisplayProperty()
Specifies the positioning of the graphic relative to the text.
|
StringProperty |
ellipsisStringProperty()
Specifies the string to display for the ellipsis when text is truncated.
|
ObjectProperty<Font> |
fontProperty()
The default font to use for text in the Labeled.
|
Pos |
getAlignment()
Gets the value of the property alignment.
|
static List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
Orientation |
getContentBias()
If wrapText is true, then contentBias will be HORIZONTAL, otherwise it is null.
|
ContentDisplay |
getContentDisplay()
Gets the value of the property contentDisplay.
|
List<CssMetaData<? extends Styleable,?>> |
getControlCssMetaData() |
String |
getEllipsisString()
Gets the value of the property ellipsisString.
|
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.
|
Insets |
getLabelPadding()
Gets the value of the property labelPadding.
|
double |
getLineSpacing()
Gets the value of the property lineSpacing.
|
String |
getText()
Gets the value of the property text.
|
TextAlignment |
getTextAlignment()
Gets the value of the property textAlignment.
|
Paint |
getTextFill()
Gets the value of the property textFill.
|
OverrunStyle |
getTextOverrun()
Gets the value of the property textOverrun.
|
ObjectProperty<Node> |
graphicProperty()
An optional icon for the Labeled.
|
DoubleProperty |
graphicTextGapProperty()
The amount of space between the graphic and text
|
boolean |
isMnemonicParsing()
Gets the value of the property mnemonicParsing.
|
boolean |
isUnderline()
Gets the value of the property underline.
|
boolean |
isWrapText()
Gets the value of the property wrapText.
|
ReadOnlyObjectProperty<Insets> |
labelPaddingProperty()
The padding around the Labeled's text and graphic content.
|
DoubleProperty |
lineSpacingProperty()
Specifies the space in pixel between lines.
|
BooleanProperty |
mnemonicParsingProperty()
MnemonicParsing property to enable/disable text parsing.
|
void |
setAlignment(Pos value)
Sets the value of the property alignment.
|
void |
setContentDisplay(ContentDisplay value)
Sets the value of the property contentDisplay.
|
void |
setEllipsisString(String value)
Sets the value of the property ellipsisString.
|
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 |
setLineSpacing(double value)
Sets the value of the property lineSpacing.
|
void |
setMnemonicParsing(boolean value)
Sets the value of the property mnemonicParsing.
|
void |
setText(String value)
Sets the value of the property text.
|
void |
setTextAlignment(TextAlignment value)
Sets the value of the property textAlignment.
|
void |
setTextFill(Paint value)
Sets the value of the property textFill.
|
void |
setTextOverrun(OverrunStyle value)
Sets the value of the property textOverrun.
|
void |
setUnderline(boolean value)
Sets the value of the property underline.
|
void |
setWrapText(boolean value)
Sets the value of the property wrapText.
|
ObjectProperty<TextAlignment> |
textAlignmentProperty()
Specifies the behavior for lines of text when text is multiline
Unlike
contentDisplayProperty() which affects the graphic and text, this setting
only affects multiple lines of text relative to the text bounds. |
ObjectProperty<Paint> |
textFillProperty()
The
Paint used to fill the text. |
ObjectProperty<OverrunStyle> |
textOverrunProperty()
Specifies the behavior to use if the text of the
Labeled
exceeds the available space for rendering the text. |
StringProperty |
textProperty()
The text to display in the label.
|
String |
toString()
Returns a string representation for the object.
|
BooleanProperty |
underlineProperty()
Whether all text should be underlined.
|
BooleanProperty |
wrapTextProperty()
If a run of text exceeds the width of the Labeled, then this variable
indicates whether the text should wrap onto another line.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, createDefaultSkin, executeAccessibleAction, getBaselineOffset, getContextMenu, getCssMetaData, getSkin, getTooltip, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinProperty, tooltipProperty
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapSize, snapSpace, snapToPixelProperty, widthProperty
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
public final StringProperty textProperty
getText()
,
setText(String)
public final ObjectProperty<Pos> alignmentProperty
getAlignment()
,
setAlignment(Pos)
public final ObjectProperty<TextAlignment> textAlignmentProperty
contentDisplayProperty()
which affects the graphic and text, this setting
only affects multiple lines of text relative to the text bounds.public final ObjectProperty<OverrunStyle> textOverrunProperty
Labeled
exceeds the available space for rendering the text.getTextOverrun()
,
setTextOverrun(OverrunStyle)
public final StringProperty ellipsisStringProperty
Examples | |
---|---|
"..." | - Default value for most locales |
" . . . " | |
" [...] " | |
"\u2026" | - The Unicode ellipsis character '…' |
"" | - No ellipsis, just display the truncated string |
Note that not all fonts support all Unicode characters.
getEllipsisString()
,
setEllipsisString(String)
public final BooleanProperty wrapTextProperty
isWrapText()
,
setWrapText(boolean)
public final ObjectProperty<Font> fontProperty
getFont()
,
setFont(Font)
public final ObjectProperty<Node> graphicProperty
setContentDisplay(javafx.scene.control.ContentDisplay)
. 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 BooleanProperty underlineProperty
isUnderline()
,
setUnderline(boolean)
public final DoubleProperty lineSpacingProperty
getLineSpacing()
,
setLineSpacing(double)
public final ObjectProperty<ContentDisplay> contentDisplayProperty
public final ReadOnlyObjectProperty<Insets> labelPaddingProperty
getLabelPadding()
public final DoubleProperty graphicTextGapProperty
getGraphicTextGap()
,
setGraphicTextGap(double)
public final ObjectProperty<Paint> textFillProperty
Paint
used to fill the text.getTextFill()
,
setTextFill(Paint)
public final BooleanProperty mnemonicParsingProperty
The default value for Labeled is false, but it is enabled by default on some Controls.
isMnemonicParsing()
,
setMnemonicParsing(boolean)
public Labeled()
public Labeled(String text)
text
- The text for the label.public final StringProperty textProperty()
getText()
,
setText(String)
public final void setText(String value)
public final String getText()
public final ObjectProperty<Pos> alignmentProperty()
getAlignment()
,
setAlignment(Pos)
public final void setAlignment(Pos value)
public final Pos getAlignment()
public final ObjectProperty<TextAlignment> textAlignmentProperty()
contentDisplayProperty()
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)
contentDisplayProperty()
which affects the graphic and text, this setting
only affects multiple lines of text relative to the text bounds.public final TextAlignment getTextAlignment()
contentDisplayProperty()
which affects the graphic and text, this setting
only affects multiple lines of text relative to the text bounds.public final ObjectProperty<OverrunStyle> textOverrunProperty()
Labeled
exceeds the available space for rendering the text.getTextOverrun()
,
setTextOverrun(OverrunStyle)
public final void setTextOverrun(OverrunStyle value)
Labeled
exceeds the available space for rendering the text.public final OverrunStyle getTextOverrun()
Labeled
exceeds the available space for rendering the text.public final StringProperty ellipsisStringProperty()
Examples | |
---|---|
"..." | - Default value for most locales |
" . . . " | |
" [...] " | |
"\u2026" | - The Unicode ellipsis character '…' |
"" | - No ellipsis, just display the truncated string |
Note that not all fonts support all Unicode characters.
getEllipsisString()
,
setEllipsisString(String)
public final void setEllipsisString(String value)
Examples | |
---|---|
"..." | - Default value for most locales |
" . . . " | |
" [...] " | |
"\u2026" | - The Unicode ellipsis character '…' |
"" | - No ellipsis, just display the truncated string |
Note that not all fonts support all Unicode characters.
public final String getEllipsisString()
Examples | |
---|---|
"..." | - Default value for most locales |
" . . . " | |
" [...] " | |
"\u2026" | - The Unicode ellipsis character '…' |
"" | - No ellipsis, just display the truncated string |
Note that not all fonts support all Unicode characters.
public final BooleanProperty wrapTextProperty()
isWrapText()
,
setWrapText(boolean)
public final void setWrapText(boolean value)
public final boolean isWrapText()
public Orientation getContentBias()
getContentBias
in class Node
Node.isResizable()
,
Node.minWidth(double)
,
Node.minHeight(double)
,
Node.prefWidth(double)
,
Node.prefHeight(double)
,
Node.maxWidth(double)
,
Node.maxHeight(double)
public final ObjectProperty<Font> fontProperty()
getFont()
,
setFont(Font)
public final void setFont(Font value)
public final Font getFont()
public final ObjectProperty<Node> graphicProperty()
setContentDisplay(javafx.scene.control.ContentDisplay)
. 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)
setContentDisplay(javafx.scene.control.ContentDisplay)
. 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.public final Node getGraphic()
setContentDisplay(javafx.scene.control.ContentDisplay)
. 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.public final BooleanProperty underlineProperty()
isUnderline()
,
setUnderline(boolean)
public final void setUnderline(boolean value)
public final boolean isUnderline()
public final DoubleProperty lineSpacingProperty()
getLineSpacing()
,
setLineSpacing(double)
public final void setLineSpacing(double value)
public final double getLineSpacing()
public final ObjectProperty<ContentDisplay> contentDisplayProperty()
public final void setContentDisplay(ContentDisplay value)
public final ContentDisplay getContentDisplay()
public final ReadOnlyObjectProperty<Insets> labelPaddingProperty()
getLabelPadding()
public final Insets getLabelPadding()
public final DoubleProperty graphicTextGapProperty()
getGraphicTextGap()
,
setGraphicTextGap(double)
public final void setGraphicTextGap(double value)
public final double getGraphicTextGap()
public final void setTextFill(Paint value)
Paint
used to fill the text.public final Paint getTextFill()
Paint
used to fill the text.public final ObjectProperty<Paint> textFillProperty()
Paint
used to fill the text.getTextFill()
,
setTextFill(Paint)
public final void setMnemonicParsing(boolean value)
The default value for Labeled is false, but it is enabled by default on some Controls.
public final boolean isMnemonicParsing()
The default value for Labeled is false, but it is enabled by default on some Controls.
public final BooleanProperty mnemonicParsingProperty()
The default value for Labeled is false, but it is enabled by default on some Controls.
isMnemonicParsing()
,
setMnemonicParsing(boolean)
public String toString()
Node
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
getControlCssMetaData
in class Control
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.