wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes enable and disable a menu item in a menu bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "enable and disable a menu item in a menu bar" Watch "enable and disable a menu item in a menu bar" New topic
Author

enable and disable a menu item in a menu bar

abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
i need to enable and disable a menu item in a menu bar,how to that.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10169
    
    8

Did you look at the the API docs for JMenuItem? Did you find any methods which would help you set the enabled state? (hint)


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
actually i am trying to do that in netbeans,but iam not getting .
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10169
    
    8

Are you writing netbeans code or java code?
Do yourself a favor and chuck out those drag and drop style IDEs. Hand coding is best.
Martijn van der Geest
Greenhorn

Joined: Jan 18, 2011
Posts: 5

Create an Action, AbstractAction for example. (Action has string or icon or both).
Remember this action in a local variable.
Construct your JMenuItem from that action.
Call someAction.setEnabled(false) whenever you need.
Cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: enable and disable a menu item in a menu bar
 
Similar Threads
Disabling short cut keys
How to Disbale ViewSource and SaveAs
diabling standard button + links in IE
adding listeners
Designing menu item State