wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame" Watch "JFrame" New topic
Author

JFrame

Rus Corina
Ranch Hand

Joined: Jul 08, 2011
Posts: 90
Hi, I have an application that consists of a main frame, and then when i press a button another frame opens. Now, I have a problem. When i close the second frame that's opened from the first one, it causes both frames to close. Do you have any idea how to avoid that? I mean, when i close the second frame, i want to close just it, not the main one as well.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Don't use EXIT_ON_CLOSE as the default close operation but DISPOSE_ON_CLOSE instead. EXIT_ON_CLOSE causes System.exit to be closed, which will terminate the entire JVM. DISPOSE_ON_CLOSE only disposes (closes) the frame itself.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rus Corina
Ranch Hand

Joined: Jul 08, 2011
Posts: 90
Thank you very much.It worked
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

You're welcome.
Sultan Ali
Greenhorn

Joined: Jul 21, 2011
Posts: 7
Use the Dispose function for that frame only when you click the button call this dispose in your actionperformed
 
Don't get me started about those stupid light bulbs.
 
subject: JFrame
 
Similar Threads
For set focus on frame..
how to disable parent jframe when child jframe is active
Array Index Out of Bounds internal frame
JFrame
Design consideration