Does anyone know of a way to 'share' JMenuItems with both JMenus and JPopupMenus - for instance: JMenuItem mniExample1 = new JMenuItem("Example 1"); JMenu mnuExample = new JMenu("Examples"); JPopupMenu pmExample = new JMenu("Examples"); mnuExample.add(mniExample1); pmExample.add(mniExample1); What happens when I do this is that the Example1 menuItem only shows up in the popup menu not both. Thanks
You should not share JMenu and JMenuItem instances. these are view components, and you definitely need an instance each time you want it displayed. what you can (and should) share is the listener that you attach to each menu item. or you can use the class Action (see the API) Chantal