• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Remove menu item when internal frame is closed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic