这里的基本思想是您将执行以下操作:
public class GameFX { private final BorderPane rootPane ; // or any other kind of pane, or Group... public GameFX() { rootPane = new BorderPane(); // build UI, register event handlers, etc etc } public Pane getRootPane() { return rootPane ; } // other methods you may need to access, etc...}现在回到
MenuFX班上
Button startButton = new Button("Start Game");startButton.setonAction(e -> { GameFX game = new GameFX(); primaryStage.getScene().setRoot(game.getRootPane());});


