It is necessary when clicking the button on the form to change the value of primaryStage.setTitle();
Main.java
package sample; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception{ Parent root = FXMLLoader.load(getClass().getResource("view.fxml")); primaryStage.setTitle("Исходная форма"); primaryStage.setScene(new Scene(root)); primaryStage.show(); primaryStage.setResizable(false); } public static void main(String[] args) { launch(args); } } Controller.java
package sample; import javafx.application.Application; import javafx.fxml.FXML; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Tooltip; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.Pane; import javafx.stage.Stage; public class Controller { @FXML public Button btnRed = new Button(); @FXML public Button btnYellow = new Button(); @FXML public Button btnGreen = new Button(); @FXML public Pane PaneM = new Pane(); Tooltip tooltipRed = new Tooltip(); Tooltip tooltipYellow = new Tooltip(); Tooltip tooltipGreen = new Tooltip(); public void tooltipsValues() { tooltipRed.setText("RED"); tooltipGreen.setText("GREEN"); tooltipYellow.setText("YELLOW"); } public void initialize(){ btnRed.setTooltip(tooltipRed); btnYellow.setTooltip(tooltipYellow); btnGreen.setTooltip(tooltipGreen); } public void onClickRed() { PaneM.setStyle("-fx-background-color: #7e1300"); btnRed.setDisable(true); btnGreen.setDisable(true); btnYellow.setDisable(false); } public void onClickYellow(){ PaneM.setStyle("-fx-background-color: #7e7d10"); btnYellow.setDisable(true); btnRed.setDisable(true); btnGreen.setDisable(false); } public void onClickGreen(){ PaneM.setStyle("-fx-background-color: #2d8e26"); btnGreen.setDisable(true); btnYellow.setDisable(true); btnRed.setDisable(false); } }