• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to just close One window?

 
Ronyn Woods
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two windows,father window and son window. Father window lanched the son window.
And then , i wanna just close the son window. How to? Thankz.
Best Regards,
Ronyn
 
Lars Tode
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
what u can do is to create a static method called closeMe i.e.
The method implements something like this :
mywindow.setVisible(false);
When u start the son window u create an instance of it like
MySon window = new MySon("Hi Dad");
If you now want to close the fathers son u called the Method closeMe like this:
window.closeMe();
And voil� the son is going away
I hope it helps
regards
Lars
 
Ronyn Woods
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i follow ur steps, maybe could get my goal, but the son window is just invisible, not destory(the object is existed). If i recall it, it will construct a new object, there are two same object.So it will waste the resource. Anymore Idea?
Thanks a lot.
Best Regards,
Ronyn
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of setVisible( false ), you could call dispose() and set the reference to null. That would get rid of the object.

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!