• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Remove menu item when internal frame is closed

 
Sylvia Allen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this app that has a JFrame with a menu, and some JInternalFrames inside that. Each JInternalFrame has its own menuitem on the menu. How can I get the menuitem to go away when its JInternalFrame is closed? I tried to find this information on the Sun tutorial site but couldn't find it. I tried several ways already but nothing has worked. A code snippet would be very much appreciated.
- SA

------------------
Sylvia Allen
sylviaa@screaminet.com
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sylvia,
The code below doesn't do exactly what you want. But it might give you the general idea of menuItem add/remove.

Enjoy,
Manfred.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, a way to do this is two ways.
1. Add a InternalFrame Listener and listen for the close event. On that event do myMenu.remove(myMenuItem)
2. Another way would be do disable the close option on the InternalFrame in the upper right corner and create a Close Button somewhere on the InternalFrame. And then add a Listener to the button and do the same as #1 above when the button is pressed but also do a dispose() for the Internal Frame to get rid of it.
Hope that helps

------------------
Happy Coding,
Gregg Bolinger
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic