aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes WindowListener not working JDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "WindowListener not working JDialog" Watch "WindowListener not working JDialog" New topic
Author

WindowListener not working JDialog

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 191

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.

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
Post your SSCCE demonstrating the problem.
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 191

Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4490
    
    8

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

Joined: Jul 24, 2006
Posts: 191

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
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

Joined: Jul 24, 2006
Posts: 191

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
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
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.

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WindowListener not working JDialog