aspose file tools*
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 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 "JFrame" Watch "JFrame" New topic
Author

JFrame

Jysh Reey
Greenhorn

Joined: Oct 10, 2011
Posts: 16
I have designed a Java program using swing , such that while pressing a button in the main window , a JFrame window appears. Actually while closing the JFrame window, i want it alone to be closed. But while closing the JFrame window my main window also gets closed. How can i avoid this?

This is my coding.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2176
    
    7
while pressing a button in the main window , a JFrame window appears. Actually while closing the JFrame window, i want it alone to be closed.


Secondary windows should be JDialogs, not JFrames. The default behaviour for a JDialog is DISPOSE_ON_CLOSE, which will only close the dialog and not the parent JFrame.
Jysh Reey
Greenhorn

Joined: Oct 10, 2011
Posts: 16
Thank you for the response . But made JFrame to close itself alone..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38412
    
  23
Rob C has pointed out the real error; you ought to correct that.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4366
    
    8

Look at line 220. What are you telling the program to do there?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JFrame