This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

WindowListener not working JDialog  RSS feed

 
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing prints out after clicking on the X in the upper right hand corner of my JDialog. I am using the Nimbus look and feel, Java 6 update 22, under Windows 7 duo processor.

 
Rancher
Posts: 3042
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE demonstrating the problem.
 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not a SSCCE...there's no main method, and it won't compile because we don't have MusiqueFrame and DocumentScrollPane. The link Rob gave explains what's needed.
 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Rob Camick
Rancher
Posts: 3042
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is about adding a WindowListener to a dialog and listening for the windowClosed event.

What do the following have to do with this requirement?

a) all the custom UIManager properties.
b) the custom Font
c) the File and Locale
d) the custom JDialog. Is this the problem? Does it work with a plain dialog?
e) etc.

The SSCCE should be about 10-15 lines of code.

The point of a SSCCE is to use the default functionality of Java to see if it works. Then if it works you see what is different between the "default" and your "custom" behavour. There you know where to look for a difference to see what is wrong. If it doesn't work then you have something simple to post and we can help if you are doing something wrong.
 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did a test with a simple JDialog and got the same results: nothing printed with println(). Keep in mind we are talking about closing the window by clicking on the red button upper right hand corner of JDialog. My program needs to know this so it can choose which JTree to keep, because I am using a JSplitpane with the possibility of removal and replacement by JS crollPane for JTree (s). Thanks. Any help appreciated.

 
Rob Camick
Rancher
Posts: 3042
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I did a test with a simple JDialog and got the same results



So where is your test code (the SSCCE)? How many times do you have to be asked?

Where are the import statements? What is the point of the JOptionPane? How is it related to the problem? There is no main() method. There is no code to create and show your dialog. Yes, it is simple to add but but you have already done this because you created a test so why should we waste time trying to duplicated something that has already been done?. You want some help, so don't make use do extra work.

I'm finished with this posting. Good luck. Maybe next time you will post a proper SSCCE.

 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Camick wrote:What is the point of the JOptionPane?
There is no code to create and show your dialog.


I think you hit the nail on the head. The extended dialog's never shown and the OP's expecting the WindowListener to be triggered by closing the JOptionPane's dialog.
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!