• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to close a JInternalFrame  RSS feed

 
Torben Hildebrandt
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first question @ JavaRanch: I've created a JInternalFrame. There is a cancel button which should close the frame. What's the method to close it?
 
Torben Hildebrandt
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I'm using "this.setVisible(false)"
 
Michael Szul
Ranch Hand
Posts: 57
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this.dispose(). I use it on pop-up windows like a Preferences window or an About window. I never used it on a JInternalFrame before, so I don't know if it'll work or not, but it's worth a shot.
 
Torben Hildebrandt
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It works, but seems to be equal with setVisible(false)...
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the API, there is a JInternalFrame.setClosed( boolean ) method that looks like what you are looking for...



-Nate
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The setVisible() and dispose() are not the same. setting a window visible(false) just makes the window not visible. It does not actually destroy the window. using the dispose() on a window will actually destroy the window and the Garbage Collector can get rid of it.
I'm sure that the setClosed(boolean) as Nathan mentioned will do the same thing. He's the expert.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!