aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to disable Menubar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to disable Menubar" Watch "How to disable Menubar" New topic
Author

How to disable Menubar

Roy Augustine
Ranch Hand

Joined: Jul 08, 2003
Posts: 30
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

Joined: Jan 14, 2004
Posts: 1535
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

Joined: Jul 08, 2003
Posts: 30
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

Joined: Jan 14, 2004
Posts: 1535
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to disable Menubar