JavaFx setOnCloseRequest & File check wait

后端 未结 1 1832
南笙
南笙 2021-01-28 04:11

I have two windows. The first one is been launched if a property file doesn\'t exist. The second is ( I want it to be) opened if the file already exists OR when the user click t

1条回答
  •  无人及你
    2021-01-28 05:07

    If you don't want to close the window, you should consume the close request event:

    if(prop.getProperty("name") != null || f.exists()) {
        primaryStage.show();
    } else {
        e.consume();
    }
    

    0 讨论(0)
提交回复
热议问题