Java - JFrame Q's

p3n

Gawd
Joined
Sep 29, 2002
Messages
631
Hey,

Im currently making the GUI and basic workings of an instant messaging program for demo purposes, no actual messages are going tobe sent.

Ive made up a 'conversation' window where whats typed in a textfield is sent to a textarea as 'you said: ****', there will eventually be some form of reply to compelte the simulation ... anyway onto the problem.

Im going to have a main window with a list of names, on clicking a name a conversation will open up with the title 'conversation with xxxx' etc

Now this is all working quite nicely the thing im worried about is if you close the conversation window with:

setDefaultCloseOperation(EXIT_ON_CLOSE)

Both windows exit on close, if i comment this line out on the conversation class then only that window is closed but will this leave the process running ?!

I've also got a small menu setup with a few options to clear/copy/paste text from the conversation, also in the 'file' menu is the old fashioned 'quit' option ... when this is selected at the moment this is run:

System.exit(0);

This also kills both windows.

Is there a defaultcloseop for just that window as such and is system.exit the wrong command for this use also ?

Thanks in advance for any help.
 
maybe you could just set that window's visibility to false at a certain point ???
 
hmmm not bad idea that would give the required effect but theres gotta be a differnet way
 
ah just found it, setDefaultCloseOperation(DISPOSE_ON_CLOSE); works brilliant .. now i need to system.exit equiv :p

edit - dispose(); worked ... thanks bye
 
Perhaps what you are looking for is the "javax.swing.WindowConstants.DISPOSE_ON_CLOSE"

******
DISPOSE_ON_CLOSE
Hide and dispose of the window when the user closes it. This removes the window from the screen and frees up any resources used by it.
******

Simply make sure that you remove any and all refferences to that frame and it will be gone for good!

Cheers!
 
p3n said:
ah just found it, setDefaultCloseOperation(DISPOSE_ON_CLOSE); works brilliant .. now i need to system.exit equiv :p

All that work I DID, for nothin! :eek:

I still want my cookie.
 
Back
Top