Switching out MenuBar – Part 2

Kevin had an interesting comment on my last blog that prompted me to write this note. First off, he gave me this suggestion to make it to work, which I think is cool.

JMenuBar newMenu = getNewMenuBar();
JFrame frame = appContext.getFrame();
frame.setJMenuBar( newMenu );
newMenu.updateUI();

Also, he asked why I am creating multiple menu bars instead of re-creating the menu items when switching contexts. I thought about it for a while and came to the following conclusion. If you switch contexts frequently, pre-creating menu bars and switching out would be beneficial, especially in scenarios where context switches need to happen on mouse overs. On the other hand, if you do context switches once in a while, it doesn’t hurt to re-create the menu items on demand.

As a side note, I create my menu items from an XML file, using Castor. If anyone is interested, I would be happy to share the code.

2 Responses

  1. JavaPro
    JavaPro January 2, 2006 at 9:46 am |

    Hi,Rajkumar:
    I’m very inetested in “Switch Menu Bar”,can you give me your codes to study how it works?

    My Email addr:
    rangwei.rcp@gmail.com

    Thx very much!
    javapro

  2. Anonymous
    Anonymous June 6, 2008 at 8:51 pm |

    Hi,

    This post is quite old now, but I’m struggling with castor and my RCP application, so I’d be glad to see how you successfuly managed to make them work together

    My email is
    frederic.gagnepain@rbc.com

    Thanks in advance.

Leave a Reply