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
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: 2182
    
    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: 38821
    
  23
Rob C has pointed out the real error; you ought to correct that.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4388
    
    8

Look at line 220. What are you telling the program to do there?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JFrame