Top Description Fields Constructors Methods
javafx.scene.control

public Class Label

extends Labeled
Class Inheritance
Known Direct Subclasses
com.sun.javafx.scene.control.ContextMenuContent.MenuLabel, com.sun.javafx.scene.control.LabeledImpl
Imports
javafx.scene.control.skin.LabelSkin, com.sun.javafx.scene.NodeHelper, javafx.beans.property.ObjectProperty, .ObjectPropertyBase, javafx.beans.value.ChangeListener, javafx.css.StyleableProperty, javafx.scene.AccessibleRole, .Node

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");
Image of the Label control
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private ObjectProperty<Node>
private ChangeListener<Boolean>

Constructor Summary

AccessConstructor and Description
public
Label()

Creates an empty label

public
Label(String
null text is treated as the empty string
text
)

Creates Label with supplied text.

public
Label(String
null text is treated as the empty string
text
,
Node
a null graphic is acceptable
graphic
)

Creates a Label with the supplied text and graphic.

Method Summary

Modifier and TypeMethod and Description
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

protected Boolean
getInitialFocusTraversable()

Overrides javafx.scene.control.Control.getInitialFocusTraversable.

Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value.

public final Node
private void
public final ObjectProperty<Node>

Returns:

the Node that this label is to be associated with
labelForProperty
()

A Label can act as a label for a different Control or Node.

public final void
Inherited from javafx.scene.control.Labeled:
alignmentPropertycontentDisplayPropertyellipsisStringPropertyfontPropertygetAlignmentgetClassCssMetaDatagetContentBiasgetContentDisplaygetControlCssMetaDatagetEllipsisStringgetFontgetGraphicgetGraphicTextGapgetInitialAlignmentgetLabelPaddinggetLineSpacinggetTextgetTextAlignmentgetTextFillgetTextOverrungraphicPropertygraphicTextGapPropertyisMnemonicParsingisTextTruncatedisUnderlineisWrapTextlabelPaddingPropertylineSpacingPropertymnemonicParsingPropertysetAlignmentsetContentDisplaysetEllipsisStringsetFontsetGraphicsetGraphicTextGapsetLineSpacingsetMnemonicParsingsetTextsetTextAlignmentsetTextFillsetTextOverrunsetUnderlinesetWrapTexttextAlignmentPropertytextFillPropertytextOverrunPropertytextPropertytextTruncatedPropertytoStringunderlinePropertywrapTextProperty

Field Detail

labelForback to summary
private ObjectProperty<Node> labelFor
mnemonicStateListenerback to summary
private ChangeListener<Boolean> mnemonicStateListener

Constructor Detail

Labelback to summary
public Label()

Creates an empty label

Labelback to summary
public Label(String text)

Creates Label with supplied text.

Parameters
text:String

null text is treated as the empty string

Labelback to summary
public Label(String text, Node graphic)

Creates a Label with the supplied text and graphic.

Parameters
text:String

null text is treated as the empty string

graphic:Node

a null graphic is acceptable

Method Detail

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

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(...).

Returns:Skin<?>

new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.

Annotations
@Override
getInitialFocusTraversableback to summary
protected Boolean getInitialFocusTraversable()

Overrides javafx.scene.control.Control.getInitialFocusTraversable.

Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value. This method is overridden as by default UI controls have focus traversable set to true, but that is not appropriate for this control.

Returns:Boolean

Doc from javafx.scene.control.Control.getInitialFocusTraversable.

the initial focus traversable state of this control

Annotations
@Override
Since
9
getLabelForback to summary
public final Node getLabelFor()
initializeback to summary
private void initialize()
labelForPropertyback to summary
public final 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:ObjectProperty<Node>

the Node that this label is to be associated with

setLabelForback to summary
public final void setLabelFor(Node value)