Stage myStage = new Stage();
Scene scene;
public void switchScene() throws IOException {
URL location = getClass().getResource("../View/character.fxml");
FXMLLoader loader = new FXMLLoader();
loader.setLocation(location);
scene = new Scene(loader.load(location.openStream()), 900, 650);
myStage.setScene(scene);
myStage.setTitle("Character Setting");
myStage.show();
}
public void exit(){
myStage.close();
}
我想关闭myStage,但是当我运行exit方法时,没有任何反应。 (我使用Controller类来触发Button来执行退出方法)
FXML:
<Button fx:id="exit" mnemonicParsing="false" onAction="#exit" text="Exit" />