Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在 JavaFX 中设置自定义关闭操作。我从 Swing 中知道这个,但在 JavaFX 中找不到它。如果您通过按 [X] 在此处关闭窗口,它将自动关闭。
您可以使用该onCloseRequest属性:
onCloseRequest
stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { System.out.println("CLOSING"); } });
请注意,如果您调用Platform.exit()代码,这将不起作用。
Platform.exit()
我知道这类问题有一些解决方案,并为这个问题应用了一些解决方案,但我无法解决,我很困惑。请帮我。这是代码:
protected String doInBackground(Boolean... params) {