The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » SwingLabs

Thread: What's the proper way to close a window

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 4 - Last Post: Jun 10, 2008 12:00 AM by: Kleopatra
jimgood

Posts: 6
What's the proper way to close a window
Posted: Jun 8, 2008 6:55 AM
  Click to reply to this thread Reply

I know this is just about as rudimentary as it gets, what is the proper way to close a window, such as a custom dialog. It seems like all of the examples in the Swing Tutorial exit on close.

My specific need is to capture the values from the input fields on a dialog when the user presses the OK button, then close the window. The only other examples I've seen are setVisible(true). Is that the correct way?

To put it another way, assuming the application is done with the window, how should it be closed while the application remains running?

Thanks.

Message was edited by: jimgood

idawes

Posts: 14
Re: What's the proper way to close a window
Posted: Jun 8, 2008 8:19 AM   in response to: jimgood
  Click to reply to this thread Reply

If you're interested in keeping the dialog around for future use, you can just call setVisible(false) on the dialog. Then when you need the dialog again, just call setVisible(true).

If you want to get release resources you can call dispose().

idawes

Posts: 14
Re: What's the proper way to close a window
Posted: Jun 8, 2008 8:28 AM   in response to: idawes
  Click to reply to this thread Reply

Oh yeah... forgot to mention that if your input is particularly simple, you don't need to make your own dialog, you can just use the show????Dialog methods from JOptionPane. They take care of lots of stuff for you, and make things look standard.

jimgood

Posts: 6
Re: What's the proper way to close a window
Posted: Jun 9, 2008 5:00 AM   in response to: idawes
  Click to reply to this thread Reply

Thanks. I think dispose() is what I was looking for.

Kleopatra
Re: What's the proper way to close a window
Posted: Jun 10, 2008 12:00 AM   in response to: jimgood
  Click to reply to this thread Reply

jdnc-interest@javadesktop.org schrieb:
> I know this is just about as rudimentary as it gets, what is the proper way to close a window, such as a custom dialog. It seems like all of the examples in the Swing Tutorial exit on close.
>
>
>

sooo ... why did you post in this forum which is highly focused on
SwingLabs related questions? Usually, you'll be better off in a more
general group/forum.

Jeanette

PS: yeah, I'm back again - reading my way through the piled-up heap of
everything and starting the easy way with one of my standards <g>





---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net





 XML java.net RSS