Prevent/Cancel closing of primary stage in JavaFX 2.2

前端 未结 4 563
小蘑菇
小蘑菇 2020-12-15 17:17

As the title says, my question is, how can I prevent/cancel closing of primary stage in JavaFX 2.2? I have done some research on Google, and the following two links seemed t

4条回答
  •  既然无缘
    2020-12-15 18:04

    I have used following code in my application and it works perfectly,

    Platform.setImplicitExit(false);
    
    primaryStage.setOnCloseRequest(new EventHandler() {
        @Override
        public void handle(WindowEvent event) {
            event.consume();
        }
    });
    

提交回复
热议问题