• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JMenuItem question

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two menus, one is a JMenu, and one is a JPopupMenu. They both have basically the same options. I, being very naive, thought I could use one set of JMenuItems for both menus. This works fine, except when I first bring up my popup menu the items disappear from the regular menu. Could someone please explain why this happens? Is there any way to reuse my menu items in this way, or do I need to go with a set for each menu?
My code looks something like this:

Thanks
Shane
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without seeing more code I'm guessing that you are only creating one instance of the menu items. If this is the case then I believe they should disappear from the first menu when added to the second menu. Maybe try adding a Factory method to create specific instances of the menu items, then you will have the same menu items class but different instances. Hope that helps, not sure if I'm being clear.
-Kevin
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic