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

JMenuItem enable

 
huguette santos
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have several JMenuItems with associated actions.
First, actions are disabled and so are the menu items.
When the status of the actions changes and they become enabled, the menu items are still disabled.
How can I force a JMenuItem to check if its action is enabled or not, update itself and displays right ?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... Take a look at the example code below and see if it works...

 
huguette santos
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your answer.
By looking at your code I understand that calling Action.setEnabled() affects also the JMenuItem.
Im my code I assumed that JMenuItem invokes Action.isEnabled before JMenuItem is drawn ... and that is not true.
Now I added a MenuListener to my menu that checks if the actions are enabled/disabled and sets the JMenuItems.
It seems to work, but I wonder if the MenuListener is always invoked before the Menu is drawn ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic