> Thanks for your answer. Maybe I havent explained myself properly. What I
> really want is to be able to cancel the close. Assume that the user presses
> the [X] and gets the question "Do you really wish to cancel". If (s)he
> responds no, the window should not be closed.
Thanks for your answer,
But how can I react on that the [X] is pressed, if it as default is set to
do nothing?
> > Thanks for your answer. Maybe I havent explained myself properly. What I
> > really want is to be able to cancel the close. Assume that the user presses
[quoted text clipped - 4 lines]
> default close operation, which is to close it. Set the default to
> do nothing.
Paul Lutus - 30 Sep 2004 17:04 GMT
> Thanks for your answer,
Do not top-post.
> But how can I react on that the [X] is pressed, if it as default is set to
> do nothing?
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
yourCodeHere(evt);
}
});

Signature
Paul Lutus
http://www.arachnoid.com
Andrew Thompson - 30 Sep 2004 17:06 GMT
> Thanks for your answer, ..
Who? Please refrain from top-posting Soeren.
<http://www.physci.org/codes/javafaq.jsp#netiquette>
> But how can I react on that the [X] is pressed, if it as default is set to
> do nothing?
Consulting the Javadocs might be a good place to start,
but you are possibly knobbling yourself by using a WindowAdapter
in the first place. implement WindowListener on the class
and you will gain full control.
A couple of clarifications though.
Are you dealing with Swing or the AWT?
Is it a frame or window that you are dealing with?

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
Andrew Thompson - 30 Sep 2004 17:13 GMT
> But how can I ...
As an aside. The example provided by Dirk displays
*exactly* the behaviour you claim to want. Did you
actually try it?
If that does not work for your problem, you need to
explain your problem again.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
Paul Lutus - 30 Sep 2004 17:16 GMT
>> But how can I ...
>
> As an aside. The example provided by Dirk displays
> *exactly* the behaviour you claim to want.
So it does. The OP now has two examples of the same code. :)

Signature
Paul Lutus
http://www.arachnoid.com
Andrew Thompson - 30 Sep 2004 17:37 GMT
>> As an aside. The example provided by Dirk displays
>> *exactly* the behaviour you claim to want.
>
> So it does. The OP now has two examples of the same code. :)
Maybe he's going for a 'hat-trick'.. ;-)