JDialog window event when closed by the parent

S

stanberka

Hi,

We have an application that has a main JFrame and a JDialog child. I'd
like to capture every possibility of closing the child window by user.
However, I'm not getting the windowClosing event on the child when the
parent is closed (which closes the whole app and the child). Is there
any way to listen to an event like this?
 
A

Andrew Thompson

stanberka wrote:
...
We have an application that has a main JFrame and a JDialog child. I'd
like to capture every possibility of closing the child window by user.
However, I'm not getting the windowClosing event on the child when the
parent is closed (which closes the whole app and the child). Is there
any way to listen to an event like this?

Why not simply make the JDialog modal?

It would make the rest of the question 'moot'.

Andrew T.
 
D

dsjoblom

Andrew said:
stanberka wrote:
..

Why not simply make the JDialog modal?

It would make the rest of the question 'moot'.

Because modal dialogs are sometimes annoying. Take for instance a basic
'Find' dialog that you'll find in many editors. Why should it not be
possible to edit text while displaying the dialog?

To the OP: try listening to the windowClosed event also.

Regards,
Daniel Sjöblom
 
A

Andrew Thompson

Because modal dialogs are sometimes annoying. Take for instance a basic
'Find' dialog that you'll find in many editors. Why should it not be
possible to edit text while displaying the dialog?

I never said it shouldn't. But let me put the question back
to you in slightly altered form.
'Why should a 'Find' dialog, block program exit?'

(And for 'Find', insert any good example of a use for a
non-modal dialog)

If a dialog is not important enough to block access to
the main GUI, it seems it is also not important enough
to interfere with the application's standard exit behaviour.

'The path of least surprise' is not being followed here.

Andrew T.
 
D

dsjoblom

Andrew said:
I never said it shouldn't. But let me put the question back
to you in slightly altered form.
'Why should a 'Find' dialog, block program exit?'

(And for 'Find', insert any good example of a use for a
non-modal dialog)

If a dialog is not important enough to block access to
the main GUI, it seems it is also not important enough
to interfere with the application's standard exit behaviour.

'The path of least surprise' is not being followed here.

Ah. I see what you mean. Certainly something to consider, and after
thinking about it, I agree with you in the general case, although I
guess there could be exceptions to this design rule. Thanks for the
clarification.

Regards,
Daniel Sjöblom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top