jQuery in Action, 2nd edition*
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: 2153
    
    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: 38007
    
  22
Rob C has pointed out the real error; you ought to correct that.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4343
    
    8

Look at line 220. What are you telling the program to do there?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame
 
Similar Threads
How to draw an etched line?
Exception in thread "main" java.lang.IllegalArgumentException: illegal component position
Multiple JFrames in 1 Container
Scrollbars
Find source of button click