wood burning stoves 2.0*
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
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: 19653
    
  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: 2153
    
    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.
 
 
subject: clicking the X button does not close a netbean developed app
 
Similar Threads
Enable/Disable Window Close X
Popup window close button
Catching Window Closing event
Bizzare behavior of Oracle
Disabling the close (X) button of the browser