Example usage for javafx.scene.control Label getLabelFor

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

Introduction

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

Prototype

public final Node getLabelFor() 

Source Link

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);/*from  www  .  j  a v a 2 s  .c om*/
    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.getLabelFor());
    stage.setScene(scene);
    stage.show();
}