Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

WindowListener not behaving like specification  RSS feed

 
Chrissy Simpson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the javadoc for the WindowClosing method in the WindowListener class it says: "If the program does not explicitly hide or dispose the window while processing this event, the window close operation will be cancelled."
I am not observing this stated behaviour. For example, when I run the following code, one would think that clicking the close button on the window would have no effect, but the window still closes. Any ideas why this is not working? I have tried this on 1.3.1 and 1.4.
Thanks.
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The behavior of javax.swing.JFrame is to automatically hide the window when the user clicks on the "close" button. That's just a convenience they added into JFrame. Check you the java docs for JFrame. However a java.awt.Frame (no J) will not hide automatically.
Note that even with a JFrame, you still need to call its dispose() method to "really" close it, otherwise it's just hidden.

[ November 18, 2002: Message edited by: Blake Minghelli ]
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it might behave as you expected when you set the default close operation to DO_NOTHING_ON_CLOSE. the preinstalled default seems to be HIDE_ON_CLOSE.
(javax.swing.WindowConstants)
Chantal
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!