• Post Reply Bookmark Topic Watch Topic
  • New Topic

menu bar enabled/dissabled  RSS feed

 
Ian Cockcroft
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am starting a GUI with a menu bar and 28 menu items in 7 menu drop down lists, I need to have all the menuItems disabled except 1 which calls a log on screen, once logged on all the menu items must be initialised. What is the best way to do this?
Thanks
Regards
Ian
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way I know how to do it is to setEnabled(boolean) on each JMenuItem.
There are a couple of methods in the JMenu API you could look at to help you type less code. There is a getMenuComponents() method that return a Component[]. There is a getItem(int) that returns a JMenuItem. And there is a getComponents() that returns a Component[].
What you could do is use one of those to get all your MenuItems at once, then loop through a routine that set's each menuItem (except the one(s) you don't want) disabled or enabled.
Hope that helps.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!