• Post Reply Bookmark Topic Watch Topic
  • New Topic

Understanding the WindowAdapter a little better

 
Jon Swanson
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a short test program because I wanted to try out using the window adapter to tell me when I disposed of my JDialogs.

It all seems to work, but there is one thing that happens which puzzled me.

If I open three dialogs, I get one message for each dialog that I open, i.e.,

Making dialog J Dialog #1
Making dialog J Dialog #2
Making dialog J Dialog #3

nothing odd there. Now I click the X on J Dialog #1
J Dialog #1 has closed

I do the same for J Dialog #2
J Dialog #2 has closed

I do the same for J Dialog #3
J Dialog #3 has closed
J Dialog #1 has closed
J Dialog #2 has closed
J Dialog #3 has closed

I'm not clear on why I get four lines instead of one when I close the last dialog. If I open a fourth dialog and then close it, I get five lines. Where do all the extra lines come from? I set the JDialogs to dispose on close, so shouldn't that also dispose of the window listener for that dialog?






 
Rob Camick
Ranch Hand
Posts: 2702
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't reproduce your problem. I only get a single message whether I open or close a dialog.

I'm using JDK8u45 on Windows 7.
 
Jon Swanson
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob,

I'm not using Java 8 (the 'official' version here is a bit behind the times, partly due to some conversion problems). I will try this in Java 8 (probably with Windows 8) when I can get to a machine.
 
Jon Swanson
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works for me as expected in Java 8 also. Sorry for wasting your time.
 
Rob Camick
Ranch Hand
Posts: 2702
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem not everybody runs the most current version (I rarely do). What you asked should work the same on all versions/platforms.

You posted a simple SSCCE with the question so it was easy to verify that it was a version/platform issue.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!