import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.layout.HBox;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.control.Label;
import javafx.stage.Stage;

public class HideShow extends Application {
    private TextField input;
    private Label lbl;
    private Button b1, b2;

    @Override
    public void start(Stage stage) {
        stage.setTitle("Hide and Show");

        lbl   = new Label("label");
        input = new TextField("text");
        b1    = new Button("Hide");
        b2    = new Button("Show");

        b1.setOnAction(e -> {
            lbl.setVisible(false); input.setVisible(false); b1.setVisible(false);
        });
        b2.setOnAction(e -> {
            lbl.setVisible(true);  input.setVisible(true);  b1.setVisible(true);
        });
        HBox root = new HBox();
        root.setAlignment(Pos.CENTER);
        root.getChildren().addAll(lbl, input, b1, b2);
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String... args) {
        launch(args);
    }
}
