This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Dynamic Menus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Dynamic Menus" Watch "Dynamic Menus" New topic
Author

Dynamic Menus

Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
Hello,
I am building an application (not an Applet) using Swing that requires different menus (within the menu bar) for each screen.
Essentially, I am trying to rebuild the menu bar for each screen, using shared components for those menu items that are common to all of the screens.
I can successfully remove all of the menus from the JMenuBar. However, when I try to add new menus to the JMenuBar, they don't appear as they should.
Can anyone explain why that is? I have tries using the remove(), removeAll(), and removeComponent() methods of JMenuBar. I have also tried creating an entirely new JMenuBar.
If anyone can provide a better way for making menus dynamic, I would definetely be open to that.
Thanks!


Jeff Wisard<br />Sun Certified Java Programmer (Java 2)<br />Sun Certified Web Component Developer
Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
I figured it out. I needed to call validate() after recreating the menus.
 
GeeCON Prague 2014
 
subject: Dynamic Menus