/*
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package javafx.scene.control;
import com.sun.javafx.scene.control.skin.LabelSkin;
import com.sun.javafx.scene.NodeHelper;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ObjectPropertyBase;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.WritableValue;
import javafx.css.StyleableProperty;
import javafx.scene.AccessibleRole;
import javafx.scene.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");
* @since JavaFX 2.0
*/
public class Label extends Labeled {
/***************************************************************************
* *
* Constructors *
* *
**************************************************************************/
/**
* Creates an empty label
*/
public Label() {
initialize();
}
/**
* Creates Label with supplied text.
* @param text null text is treated as the empty string
*/
public Label(String text) {
super(text);
initialize();
}
/**
* Creates a Label with the supplied text and graphic.
* @param text null text is treated as the empty string
* @param graphic a null graphic is acceptable
*/
public Label(String text, Node graphic) {
super(text, graphic);
initialize();
}
private void initialize() {
getStyleClass().setAll("label");
setAccessibleRole(AccessibleRole.TEXT);
// Labels are not focus traversable, unlike most other UI Controls.
// focusTraversable is styleable through css. Calling setFocusTraversable
// makes it look to css like the user set the value and css will not
// override. Initializing focusTraversable by calling set on the
// CssMetaData ensures that css will be able to override the value.
((StyleableProperty