This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 2090
    
    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: 36453
    
  15
Rob C has pointed out the real error; you ought to correct that.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4240
    
    7

Look at line 220. What are you telling the program to do there?
 
wood burning stoves
 
subject: JFrame
 
Similar Threads
How to draw an etched line?
Scrollbars
Multiple JFrames in 1 Container
Find source of button click
Exception in thread "main" java.lang.IllegalArgumentException: illegal component position