• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

clicking the X button does not close a netbean developed app

 
Ahmad Ras
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20492
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a WindowListener added to the frame?
 
Ahmad Ras
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2534
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic