Example usage for javafx.scene.control Button textProperty

List of usage examples for javafx.scene.control Button textProperty

Introduction

In this page you can find the example usage for javafx.scene.control Button textProperty.

Prototype

public final StringProperty textProperty() 

Source Link

Document

The text to display in the label.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Button b1 = new Button("B1");
    Button b2 = new Button("B2");
    Button b3 = new Button("B3");
    Button visibleBtn = new Button("Make Invisible");

    visibleBtn.setOnAction(e -> b2.setVisible(!b2.isVisible()));

    visibleBtn.textProperty().bind(new When(b2.visibleProperty()).then("Invisible").otherwise("Visible"));

    b2.managedProperty().bind(b2.visibleProperty());

    HBox root = new HBox();
    root.getChildren().addAll(visibleBtn, b1, b2, b3);

    Scene scene = new Scene(root);
    stage.setScene(scene);//from  w  w w.  j a v a  2  s.  c om
    stage.setTitle("");
    stage.show();
}