• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to disable Menubar

 
Roy Augustine
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I created a menubar, I just want to disable the menus, once I selected one of the menu items until I finish with that one( like in most windows applications, once we select a menuItem like File- new - the menus will be disabled until we are done ). I couldn�t find a method to disable the menubar. I know there is an option to disable the Frame. Is that the only option.
Thanks in advance
Roy
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't clear whether you are working in AWT or Swing. Let's start with AWT. Looking in the api, scroll down in the left lower frame to the MenuBar class and click on the link. Look down in the Methods and inherited methods blocks - sure enough, no setEnabled method.

Let's try the Menu api. We find setEnabled in the Methods inherited from class java.awt.MenuItem. So we can use it to en/disable menus. Same with MenuItem.

In Swing, setEnabled is available for all three components: JMenuBar, JMenu and JMenuItem.
 
Roy Augustine
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
I am sorry I didn�t give the full information. Actually I am using swing.
Yes I tried
menuBar.setEnabled(false);
but it is not working. I tried the other two, menuItem and menu and calling setEnabled(false) disable them, But I don�t know what is happening with menuBar. Am I doing something wrong? Since I want to disable the entire menubar I think if I can disable the menubar that will be the best choice.
Any help
Roy.
[ January 18, 2004: Message edited by: Roy Augustine ]
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right. I checked the JMenuBar api, finding setEnabled in the JComponent section. Following the link I find this in the method detail:
Note: Disabling a component does not disable it's children.

Looks like a dead end...

[ January 19, 2004: Message edited by: Craig Wood ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic