I am trying to stop the window close from exiting a form when running forms 12c in web start configuration. I would like to stop the window close command and tell the user to use the form's toolbar exit button. I am defining the window close as either using the red X in the top right hand corner of the frame in which the form is running, or from the icon in the top left hand corner then selecting Close.
I am trying to use a java bean that extends VBean and I can find the frame and I am trying to stop the default behavior using
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent ev) {
}
});
I think I can get to the JFrame using
jfr = (JFrame) formsTopFrame;
and then I add a an adapter to override the existing one using
jfr.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent ev) {
int i = JOptionPane.showConfirmDialog(jfr,
"Please use toolbar button to exit the application", "Closing dialog",
JOptionPane.DEFAULT_OPTION);
}
});
And try to stop the default close using jfr.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE).
The result of this is that the window closes but I can see the dialog being displayed before the close. So, can you see why my attempts to stop the default close processing fail, or is there a better way to do this?