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
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private ObjectProperty | |
| private ObjectProperty | |
| private static final String | |
| private StringProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private DoubleProperty | |
| private StyleableStringProperty | |
| private ObjectProperty | |
| private DoubleProperty | |
| private BooleanProperty | mnemonicParsing
MnemonicParsing property to enable/disable text parsing. |
| private StringProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private ReadOnlyBooleanWrapper | textTruncated
Indicates whether the text has been truncated because it cannot fit into the available width. |
| private BooleanProperty | |
| private BooleanProperty |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final ObjectProperty | Returns: the alignment within this labeledSpecifies how the text and graphic within the Labeled should be aligned when there is empty space within the Labeled. |
| public final ObjectProperty | Returns: content display property of this labeledSpecifies the positioning of the graphic relative to the text. |
| public final StringProperty | Returns: the ellipsis property on the string to display for the ellipsis when text is truncatedSpecifies the string to display for the ellipsis when text is truncated. |
| public final ObjectProperty | Returns: the default font to use for text in this labeledThe default font to use for text in the Labeled. |
| public final Pos | |
| public static List | Returns: theCssMetaDataHides javafx. Gets the |
| public Orientation | Returns: orientation of width/height dependency or null if there is noneOverrides javafx. If wrapText is true, then contentBias will be HORIZONTAL, otherwise it is null. |
| public final ContentDisplay | |
| public List | getControlCssMetaData()
Overrides javafx. Gets the unmodifiable list of the control's CSS-styleable properties. |
| public final String | |
| public final Font | |
| public final Node | |
| public final double | |
| protected Pos | Returns: the initial alignment state of this controlReturns the initial alignment state of this control, for use by the JavaFX CSS engine to correctly set its initial value. |
| public final Insets | |
| public final double | |
| public final String | |
| public final TextAlignment | |
| public final Paint | |
| public final OverrunStyle | |
| public final ObjectProperty | |
| public final DoubleProperty | Returns: the graphics text gap property of this labeledThe amount of space between the graphic and text |
| private StyleableStringProperty | imageUrlProperty()
The imageUrl property is set from CSS and then the graphic property is set from the invalidated method. |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| public final ReadOnlyObjectProperty | Returns: the label padding property of this labeledThe padding around the Labeled's text and graphic content. |
| private ObjectProperty | |
| public final DoubleProperty | Returns: the line spacing property between lines in this labeledSpecifies the space in pixel between lines. |
| public final BooleanProperty | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| private void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| private final void | |
| public final void | |
| public final void | |
| public final ObjectProperty | Returns: the alignment of lines of text within this labeledSpecifies the behavior for lines of text when text is multiline. |
| public final ObjectProperty | |
| public final ObjectProperty | Returns: the overrun behavior if the text exceeds the available spaceSpecifies the behavior to use if the text of the |
| public final StringProperty | |
| private ReadOnlyBooleanWrapper | |
| public final ReadOnlyBooleanProperty | |
| public String | |
| public final BooleanProperty | Returns: the underline property of all text in this labeledWhether all text should be underlined. |
| public final BooleanProperty | Returns: the wrap property if a run of text exceeds the width of the LabeledIf a run of text exceeds the width of the Labeled, then this variable indicates whether the text should wrap onto another line. |
| alignment | back to summary |
|---|---|
| private ObjectProperty<Pos> alignment | |
| contentDisplay | back to summary |
|---|---|
| private ObjectProperty<ContentDisplay> contentDisplay | |
| DEFAULT_ELLIPSIS_STRING | back to summary |
|---|---|
| private static final String DEFAULT_ELLIPSIS_STRING | |
| ellipsisString | back to summary |
|---|---|
| private StringProperty ellipsisString | |
| font | back to summary |
|---|---|
| private ObjectProperty<Font> font | |
| graphic | back to summary |
|---|---|
| private ObjectProperty<Node> graphic | |
| graphicTextGap | back to summary |
|---|---|
| private DoubleProperty graphicTextGap | |
| imageUrl | back to summary |
|---|---|
| private StyleableStringProperty imageUrl | |
| labelPadding | back to summary |
|---|---|
| private ObjectProperty<Insets> labelPadding | |
| lineSpacing | back to summary |
|---|---|
| private DoubleProperty lineSpacing | |
| mnemonicParsing | back to summary |
|---|---|
| private BooleanProperty mnemonicParsing MnemonicParsing property to enable/disable text parsing. If this is set to true, then the Label text will be parsed to see if it contains the mnemonic parsing character '_'. When a mnemonic is detected the key combination will be determined based on the succeeding character, and the mnemonic added.
| |
| text | back to summary |
|---|---|
| private StringProperty text | |
| textAlignment | back to summary |
|---|---|
| private ObjectProperty<TextAlignment> textAlignment | |
| textFill | back to summary |
|---|---|
| private ObjectProperty<Paint> textFill The
| |
| textOverrun | back to summary |
|---|---|
| private ObjectProperty<OverrunStyle> textOverrun | |
| textTruncated | back to summary |
|---|---|
| private ReadOnlyBooleanWrapper textTruncated Indicates whether the text has been truncated because it cannot fit into the available width.
When truncated, the
| |
| underline | back to summary |
|---|---|
| private BooleanProperty underline | |
| wrapText | back to summary |
|---|---|
| private BooleanProperty wrapText | |
| Labeled | back to summary |
|---|---|
| public Labeled() Creates a Label with no text and graphic | |
| Labeled | back to summary |
|---|---|
| public Labeled(String text) Creates a Label with text
| |
| Labeled | back to summary |
|---|---|
| public Labeled(String text, Node graphic) Creates a Label with text and a graphic | |
| alignmentProperty | back to summary |
|---|---|
| public final ObjectProperty Specifies how the text and graphic within the Labeled should be aligned when there is empty space within the Labeled.
| |
| contentDisplayProperty | back to summary |
|---|---|
| public final ObjectProperty Specifies the positioning of the graphic relative to the text.
| |
| ellipsisStringProperty | back to summary | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public final StringProperty ellipsisStringProperty() Specifies the string to display for the ellipsis when text is truncated.
Note that not all fonts support all Unicode characters.
| |||||||||||||
| fontProperty | back to summary |
|---|---|
| public final ObjectProperty The default font to use for text in the Labeled. If the Label'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.
| |
| getAlignment | back to summary |
|---|---|
| public final Pos getAlignment() | |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Gets the
| |
| getContentBias | back to summary |
|---|---|
| public Orientation getContentBias() Overrides javafx. If wrapText is true, then contentBias will be HORIZONTAL, otherwise it is null.
| |
| getContentDisplay | back to summary |
|---|---|
| public final ContentDisplay getContentDisplay() | |
| getControlCssMetaData | back to summary |
|---|---|
| public List Overrides javafx. Doc from javafx. Gets the unmodifiable list of the control's CSS-styleable properties.
| |
| getEllipsisString | back to summary |
|---|---|
| public final String getEllipsisString() | |
| getFont | back to summary |
|---|---|
| public final Font getFont() | |
| getGraphic | back to summary |
|---|---|
| public final Node getGraphic() | |
| getGraphicTextGap | back to summary |
|---|---|
| public final double getGraphicTextGap() | |
| getInitialAlignment | back to summary |
|---|---|
| protected Pos getInitialAlignment() Returns the initial alignment state of this control, for use by the JavaFX CSS engine to correctly set its initial value. This method is overridden to use Pos.CENTER_LEFT initially.
| |
| getLabelPadding | back to summary |
|---|---|
| public final Insets getLabelPadding() | |
| getLineSpacing | back to summary |
|---|---|
| public final double getLineSpacing() | |
| getText | back to summary |
|---|---|
| public final String getText() | |
| getTextAlignment | back to summary |
|---|---|
| public final TextAlignment getTextAlignment() | |
| getTextFill | back to summary |
|---|---|
| public final Paint getTextFill() | |
| getTextOverrun | back to summary |
|---|---|
| public final OverrunStyle getTextOverrun() | |
| graphicProperty | back to summary |
|---|---|
| public final ObjectProperty An optional icon for the Labeled. This can be positioned relative to the
text by using
| |
| graphicTextGapProperty | back to summary |
|---|---|
| public final DoubleProperty graphicTextGapProperty() The amount of space between the graphic and text
| |
| imageUrlProperty | back to summary |
|---|---|
| private StyleableStringProperty imageUrlProperty() The imageUrl property is set from CSS and then the graphic property is set from the invalidated method. This ensures that the same image isn't reloaded. | |
| isMnemonicParsing | back to summary |
|---|---|
| public final boolean isMnemonicParsing() | |
| isTextTruncated | back to summary |
|---|---|
| public final boolean isTextTruncated() | |
| isUnderline | back to summary |
|---|---|
| public final boolean isUnderline() | |
| isWrapText | back to summary |
|---|---|
| public final boolean isWrapText() | |
| labelPaddingProperty | back to summary |
|---|---|
| public final ReadOnlyObjectProperty The padding around the Labeled's text and graphic content. By default labelPadding is Insets.EMPTY and cannot be set to null. Subclasses may add nodes outside this padding and inside the Labeled's padding. This property can only be set from CSS.
| |
| labelPaddingPropertyImpl | back to summary |
|---|---|
| private ObjectProperty | |
| lineSpacingProperty | back to summary |
|---|---|
| public final DoubleProperty lineSpacingProperty() Specifies the space in pixel between lines.
| |
| mnemonicParsingProperty | back to summary |
|---|---|
| public final BooleanProperty mnemonicParsingProperty() | |
| setAlignment | back to summary |
|---|---|
| public final void setAlignment(Pos value) | |
| setContentDisplay | back to summary |
|---|---|
| public final void setContentDisplay(ContentDisplay value) | |
| setEllipsisString | back to summary |
|---|---|
| public final void setEllipsisString(String 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) | |
| setLabelPadding | back to summary |
|---|---|
| private void setLabelPadding(Insets value) | |
| setLineSpacing | back to summary |
|---|---|
| public final void setLineSpacing(double value) | |
| setMnemonicParsing | back to summary |
|---|---|
| public final void setMnemonicParsing(boolean value) | |
| setText | back to summary |
|---|---|
| public final void setText(String value) | |
| setTextAlignment | back to summary |
|---|---|
| public final void setTextAlignment(TextAlignment value) | |
| setTextFill | back to summary |
|---|---|
| public final void setTextFill(Paint value) | |
| setTextOverrun | back to summary |
|---|---|
| public final void setTextOverrun(OverrunStyle value) | |
| setTextTruncated | back to summary |
|---|---|
| private final void setTextTruncated(boolean on) | |
| setUnderline | back to summary |
|---|---|
| public final void setUnderline(boolean value) | |
| setWrapText | back to summary |
|---|---|
| public final void setWrapText(boolean value) | |
| textAlignmentProperty | back to summary |
|---|---|
| public final ObjectProperty Specifies the behavior for lines of text when text is multiline.
Unlike
| |
| textFillProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| 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 label. The text may be null.
| |
| textTruncated | back to summary |
|---|---|
| private ReadOnlyBooleanWrapper textTruncated() | |
| textTruncatedProperty | back to summary |
|---|---|
| public final ReadOnlyBooleanProperty textTruncatedProperty() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides javafx. Doc from javafx. Returns a string representation for the object. | |
| underlineProperty | back to summary |
|---|---|
| public final BooleanProperty underlineProperty() Whether all text should be underlined.
| |
| wrapTextProperty | back to summary |
|---|---|
| public final 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.
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final FontCssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final List | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData |
| Access | Constructor and Description |
|---|---|
| private |
| ALIGNMENT | back to summary |
|---|---|
| private static final CssMetaData<Labeled, Pos> ALIGNMENT | |
| CONTENT_DISPLAY | back to summary |
|---|---|
| private static final CssMetaData<Labeled, ContentDisplay> CONTENT_DISPLAY | |
| ELLIPSIS_STRING | back to summary |
|---|---|
| private static final CssMetaData<Labeled, String> ELLIPSIS_STRING | |
| FONT | back to summary |
|---|---|
| private static final FontCssMetaData<Labeled> FONT | |
| GRAPHIC | back to summary |
|---|---|
| private static final CssMetaData<Labeled, String> GRAPHIC | |
| GRAPHIC_TEXT_GAP | back to summary |
|---|---|
| private static final CssMetaData<Labeled, Number> GRAPHIC_TEXT_GAP | |
| LABEL_PADDING | back to summary |
|---|---|
| private static final CssMetaData<Labeled, Insets> LABEL_PADDING | |
| LINE_SPACING | back to summary |
|---|---|
| private static final CssMetaData<Labeled, Number> LINE_SPACING | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| TEXT_ALIGNMENT | back to summary |
|---|---|
| private static final CssMetaData<Labeled, TextAlignment> TEXT_ALIGNMENT | |
| TEXT_FILL | back to summary |
|---|---|
| private static final CssMetaData<Labeled, Paint> TEXT_FILL | |
| TEXT_OVERRUN | back to summary |
|---|---|
| private static final CssMetaData<Labeled, OverrunStyle> TEXT_OVERRUN | |
| UNDERLINE | back to summary |
|---|---|
| private static final CssMetaData<Labeled, Boolean> UNDERLINE | |
| WRAP_TEXT | back to summary |
|---|---|
| private static final CssMetaData<Labeled, Boolean> WRAP_TEXT | |
| StyleableProperties | back to summary |
|---|---|
| private StyleableProperties() | |