Example usage for javafx.scene.control Label labelForProperty

List of usage examples for javafx.scene.control Label labelForProperty

Introduction

In this page you can find the example usage for javafx.scene.control Label labelForProperty.

Prototype

public ObjectProperty<Node> labelForProperty() 

Source Link

Document

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

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Label Sample");
    stage.setWidth(400);//w ww  .j  a v  a 2 s .  c  o m
    stage.setHeight(180);

    HBox hbox = new HBox();
    Image image = new Image(getClass().getResourceAsStream("labels.jpg"));
    Label label1 = new Label("Search", new ImageView(image));

    hbox.setSpacing(10);
    hbox.getChildren().add((label1));
    ((Group) scene.getRoot()).getChildren().add(hbox);

    label1.setLabelFor(hbox);
    System.out.println(label1.labelForProperty());
    stage.setScene(scene);
    stage.show();
}