Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

enable and disable a menu item in a menu bar

 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to enable and disable a menu item in a menu bar,how to that.
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you look at the the API docs for JMenuItem? Did you find any methods which would help you set the enabled state? (hint)
 
abhishek rathur
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i am trying to do that in netbeans,but iam not getting .
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
Chrome IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic