@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
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() |
static List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
Orientation |
getContentBias()
If wrapText is true, then contentBias will be HORIZONTAL, otherwise it is null.
|
ContentDisplay |
getContentDisplay() |
List<CssMetaData<? extends Styleable,?>> |
getControlCssMetaData() |
String |
getEllipsisString() |
Font |
getFont() |
Node |
getGraphic() |
double |
getGraphicTextGap() |
Insets |
getLabelPadding() |
double |
getLineSpacing() |
String |
getText() |
TextAlignment |
getTextAlignment() |
Paint |
getTextFill() |
OverrunStyle |
getTextOverrun() |
ObjectProperty<Node> |
graphicProperty()
An optional icon for the Labeled.
|
DoubleProperty |
graphicTextGapProperty()
The amount of space between the graphic and text
|
protected Pos |
impl_cssGetAlignmentInitialValue()
Deprecated.
|
boolean |
isMnemonicParsing() |
boolean |
isUnderline() |
boolean |
isWrapText() |
ReadOnlyObjectProperty<Insets> |
labelPaddingProperty()
The padding around the Labeled's text and graphic content.
|
DoubleProperty |
lineSpacingProperty()
Specifies the space in pixel between lines.
|
BooleanProperty |
mnemonicParsingProperty() |
void |
setAlignment(Pos value) |
void |
setContentDisplay(ContentDisplay value) |
void |
setEllipsisString(String value) |
void |
setFont(Font value) |
void |
setGraphic(Node value) |
void |
setGraphicTextGap(double value) |
void |
setLineSpacing(double value) |
void |
setMnemonicParsing(boolean value) |
void |
setText(String value) |
void |
setTextAlignment(TextAlignment value) |
void |
setTextFill(Paint value) |
void |
setTextOverrun(OverrunStyle value) |
void |
setUnderline(boolean value) |
void |
setWrapText(boolean value) |
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() |
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, impl_cssGetFocusTraversableInitialValue, impl_processCSS, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipProperty
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, 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, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, 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, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, 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 Labeled()
public Labeled(String text)
text
- The text for the label.public final StringProperty textProperty()
public final void setText(String value)
public final String getText()
public final ObjectProperty<Pos> alignmentProperty()
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)
public final TextAlignment getTextAlignment()
public final ObjectProperty<OverrunStyle> textOverrunProperty()
Labeled
exceeds the available space for rendering the text.public final void setTextOverrun(OverrunStyle value)
public final OverrunStyle getTextOverrun()
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.
public final void setEllipsisString(String value)
public final String getEllipsisString()
public final BooleanProperty wrapTextProperty()
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()
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.public final void setGraphic(Node value)
public final Node getGraphic()
public final BooleanProperty underlineProperty()
public final void setUnderline(boolean value)
public final boolean isUnderline()
public final DoubleProperty lineSpacingProperty()
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()
public final Insets getLabelPadding()
public final DoubleProperty graphicTextGapProperty()
public final void setGraphicTextGap(double value)
public final double getGraphicTextGap()
public final void setTextFill(Paint value)
public final Paint getTextFill()
public final ObjectProperty<Paint> textFillProperty()
public final void setMnemonicParsing(boolean value)
public final boolean isMnemonicParsing()
public final BooleanProperty mnemonicParsingProperty()
public String toString()
Node
@Deprecated protected Pos impl_cssGetAlignmentInitialValue()
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
getControlCssMetaData
in class Control
Copyright © 2020. All rights reserved.