How to destroy a window

C

Click

Hello all.

I have a question that might seem stupid to most of you, but I cannot find
how to do it.

How can I destroy a window (JFrame)? I mean not by exiting the application.
But just destroying the window so that my app can go on. I know that just
setting the pointer to my window to null will not destroy it.
I just cant find it in the docs! The docs say that "dispose" releases the
resources used by the window, but not the window itself.

Thanks for helping me!

Francois
 
D

Daniel Pitts

Jason said:
As far as I know, destroy() does what you're looking to do (assuming
you don't have the problems below). destroy() does not necessarily
exit the JVM - it only *can* do that if the window you destroyed was
the last one.

As far as "destroying the window so my app can go on" - that sounds
more like a problem with the window itself. Is the window expecting
some input before the app can continue? Are you doing "work" in the
EventQueue thread?
dispose() will close the window.
 
J

Jason Cavett

Hello all.

I have a question that might seem stupid to most of you, but I cannot find
how to do it.

How can I destroy a window (JFrame)? I mean not by exiting the application.
But just destroying the window so that my app can go on. I know that just
setting the pointer to my window to null will not destroy it.
I just cant find it in the docs! The docs say that "dispose" releases the
resources used by the window, but not the window itself.

Thanks for helping me!

Francois

As far as I know, destroy() does what you're looking to do (assuming
you don't have the problems below). destroy() does not necessarily
exit the JVM - it only *can* do that if the window you destroyed was
the last one.

As far as "destroying the window so my app can go on" - that sounds
more like a problem with the window itself. Is the window expecting
some input before the app can continue? Are you doing "work" in the
EventQueue thread?
 
M

Matt Humphrey

| Hello all.
|
| I have a question that might seem stupid to most of you, but I cannot find
| how to do it.
|
| How can I destroy a window (JFrame)? I mean not by exiting the
application.
| But just destroying the window so that my app can go on. I know that just
| setting the pointer to my window to null will not destroy it.
| I just cant find it in the docs! The docs say that "dispose" releases the
| resources used by the window, but not the window itself.

dispose() is what you want. If it makes you feel better you can
setVisible(false) first to make the visual aspects of the window disappear
first, but really the visual appearance of the window (vs. its internal data
structure) is part of the resources that are being disposed of. It will
vanish on its own when you call dispose(). After that you can set your
window refs to null and the GC will do the rest.

Matt Humphrey http://www.iviz.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top