Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes clicking the X button does not close a netbean developed app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "clicking the X button does not close a netbean developed app" Watch "clicking the X button does not close a netbean developed app" New topic
Author

clicking the X button does not close a netbean developed app

Ahmad Ras
Greenhorn

Joined: Jun 09, 2010
Posts: 11
Hey
I am using netbeans to handle my GUI however when I click on the X button to exit, the window is gone but the application remains running in the background. However, going through file-> exit will close the whole thing. How can I capture the window close event or make sure the window is closed?

I searched in the form and I found the mainFrame.setDefaultCloseOperation(mainFrame.DISPOSE_ON_CLOSE); //or even exit on close

but it does not seem to work, ideas?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19674
    
  18

Is there a WindowListener added to the frame?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ahmad Ras
Greenhorn

Joined: Jun 09, 2010
Posts: 11
I added a windows listener to the frame that but no luck. Wehn I debugged it , it seems that the code of "closing window" is not being hit. I see the code for every thing inside the frame but I can't find the generated code that deals with creating the frame and its specs. hmmm
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2177
    
    7
I found the mainFrame.setDefaultCloseOperation(mainFrame.DISPOSE_ON_CLOSE);


Search your code. Make sure that method is only invoked once. NetBeans probably also uses this method so your method call is ignored.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: clicking the X button does not close a netbean developed app