Class Label

All Implemented Interfaces:
LayoutMeasurable, LayoutMeasurableMixin, HasAlignmentProperty, HasBackgroundProperty, HasBlendModeProperty, HasBorderProperty, HasClipProperty, HasEffectProperty, HasFontProperty, HasGraphicProperty, HasHeightProperty, HasImageUrlProperty, HasLayoutXProperty, HasLayoutYProperty, HasManagedProperty, HasMaxHeightProperty, HasMaxWidthProperty, HasMinHeightProperty, HasMinWidthProperty, HasMouseTransparentProperty, HasOnMouseClickedProperty, HasOpacityProperty, HasPaddingProperty, HasParentProperty, HasPrefHeightProperty, HasPrefWidthProperty, HasSnapToPixelProperty, HasTextAlignmentProperty, HasTextFillProperty, HasTextProperty, HasVisibleProperty, HasWidthProperty, Styleable, EventTarget, Skinnable, INode, PreferenceResizableNode

public class Label extends Labeled
Label is a non-editable text control. A Label is useful for displaying text that is required to fit within a specific space, and thus may need to use an ellipsis or truncation to size the string to fit. Labels also are useful in that they can have mnemonics which, if used, will send focus to the Control listed as the target of the labelFor property.

Label sets focusTraversable to false.

Example:

Label label = new Label("a label");
Since:
JavaFX 2.0
  • Property Details

  • Constructor Details

    • Label

      public Label()
      Creates an empty label
    • Label

      public Label(String text)
      Creates Label with supplied text.
      Parameters:
      text - null text is treated as the empty string
    • Label

      public Label(String text, Node graphic)
      Creates a Label with the supplied text and graphic.
      Parameters:
      text - null text is treated as the empty string
      graphic - a null graphic is acceptable
  • Method Details

    • labelForProperty

      public ObjectProperty<Node> labelForProperty()
      A Label can act as a label for a different Control or Node. This is used for Mnemonics and Accelerator parsing. This allows setting of the target Node.
      Returns:
      the labelFor property
      See Also:
    • setLabelFor

      public final void setLabelFor(Node value)
      Sets the value of the labelFor property.
      Property description:
      A Label can act as a label for a different Control or Node. This is used for Mnemonics and Accelerator parsing. This allows setting of the target Node.
      Parameters:
      value - the value for the labelFor property
      See Also:
    • getLabelFor

      public final Node getLabelFor()
      Gets the value of the labelFor property.
      Property description:
      A Label can act as a label for a different Control or Node. This is used for Mnemonics and Accelerator parsing. This allows setting of the target Node.
      Returns:
      the value of the labelFor property
      See Also:
    • createDefaultSkin

      protected Skin<?> createDefaultSkin()
      Description copied from class: Control
      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 -fx-skin or set explicitly in a sub-class with setSkin(...).
      Overrides:
      createDefaultSkin in class Control
      Returns:
      new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.