JavaFX Sync Duplicate Views to the Same Controller (FXML & MVC)
问题 Below is a small Application that illustrates the problem: ButtonPanel.fxml <ScrollPane fx:controller="ButtonPanelController"> <VBox> <Button fx:id="myButton" text="Click Me" onAction="#buttonClickedAction" /> </VBox> </ScrollPane> ButtonPanelController.java public class ButtonPanelController { @FXML Button myButton; boolean isRed = false; public void buttonClickedAction(ActionEvent event) { if(isRed) { myButton.setStyle(""); } else { myButton.setStyle("-fx-background-color: red"); } isRed =