0
我开始使用它自己的控制器的第二个场景。我想从另一个类访问该控制器中的一个方法。我如何获得新的场景控制器的句柄?如何获得新阶段的控制器控制器JavaFX
public void startNewScene() throws IOException{
Stage stage = new Stage();
Partent root;
root = FXMLLoader.load(getClass().getResource("fxmlfile.fxml");
Scene scene = new Scene(root);
Stage.setScene(scene);
stage.show();
}
我得到ClassCastException AnchorPane无法转换为FXMLLoader。我也将其更改为BorderPane,我得到相同的错误无法投射到FXMLLoader – Moe
@Moe你复制了我的代码错误 –
你是对的!而不是做新的FXMLLoader(getClass())我做了FXMLLoader.load(getClass()); thx为您的帮助! – Moe