wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Dynamically changing a JMenuBar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Dynamically changing a JMenuBar" Watch "Dynamically changing a JMenuBar" New topic

Dynamically changing a JMenuBar

Christian Waidner

Joined: Mar 29, 2001
Posts: 6
I have an applet running which displays a JMenuBar. I wonder if there is any way to change the menu while the application is running. I tried another call to the applet's setJMenuBar(mymenu) but then all menus just disappear.
I have not overridden any paint methods, so where's the problem?
Thanks in advance,

Christian Waidner<BR>Hirschbiegel & Grundstein GmbH<BR>http://www.hg-online.de
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
You were, of course, adding this JMenuBar to a JApplet, not a regular Applet? Maybe you could try:

before adding the new one. Then after it is added, you could also make a call to getMenuBar() just to see if it worked.
Christian Waidner

Joined: Mar 29, 2001
Posts: 6
Yep, JApplet.
I solved this problem 10 minutes ago. Seems to be the old Swing updating problem (grrrrrrr). Just invalidate every component except the last one, the validate and it's ok.
I agree. Here's the link: http://aspose.com/file-tools
subject: Dynamically changing a JMenuBar
Similar Threads
JMenuBar not using default alignment?
Run JApplet and no JMenuBar - Help!!
Setting the null layout for JMenuBar in JApplet
JApplet containing JTextfields within a JMenubar