JDK-8101097 : No way to cancel Stage closing
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: fx2.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2011-06-16
  • Updated: 2015-06-16
  • Resolved: 2011-07-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
fx2.0Fixed
Related Reports
Blocks :  
Duplicate :  
Relates :  
Description
I want to cancel a stage being closed using the Window Manager close button. I want to keep the Stage visible, show a popup asking for close confirmation.

I tried on onHidden and onHiding to restore the visibility of the Stage, but I got an Exception saying that the Window is already closed.


Comments
Changeset: 36d6afc06821 Author: Lubomir Nerad <lubomir.nerad@oracle.com> Date: Mon Jul 11 16:38:08 2011 +0200 URL: http://jfxsrc.us.oracle.com/javafx/presidio/scrum/graphics/runtime/rev/36d6afc06821 Description: Fix for RT-14297: window close request event and handler Changeset: fcfe6952a7dd Author: Lubomir Nerad <lubomir.nerad@oracle.com> Date: Mon Jul 11 18:19:46 2011 +0200 URL: http://jfxsrc.us.oracle.com/javafx/presidio/scrum/graphics/runtime/rev/fcfe6952a7dd Description: Fix for RT-14297: window close request event and handler
11-07-2011

Non-existence of Alert dialog is not a stopper for this feature. It can be used with non-blocking dialogs in the following way: stage.setOnCloseRequest( new EventHandler<WindowEvent>() { public void handle(final WindowEvent event) { dialog.setVisible(true); event.consume(); } }); dialog.setOnConfirm( new ...() { public void handle(...) { stage.close(); } });
11-07-2011

OK / SQE
07-07-2011

Btw, without the addition of an Alert dialog class, there will be no way to show a blocking dialog.
06-07-2011

This is a feature request not a bug.
06-07-2011

OK / Arch
01-07-2011

OK / RM
27-06-2011

OK / Dev (for Nandini Ramani)
27-06-2011

SQE: will require 1 day of test development
27-06-2011

This is fine for the Visual Tool requirement.
27-06-2011

Justification: Useful feature for document based applications. Without this feature such applications will need to save the document changes automatically or the changes will be lost. Both options are not very user friendly. Development effort: 2 days
27-06-2011

I plan to add a new WindowEvent type (WINDOW_CLOSE_REQUEST) and a new event handler property (onCloseRequest) for it to Window. Developers can then install an event handler for this new event and display close confirmation dialog in it: stage.setOnCloseRequest( new EventHandler<WindowEvent>() { public void handle(final WindowEvent event) { // show dialog / wait for user choice if (!cancel) { stage.close(); } event.consume(); } });
27-06-2011