It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes JMenuItem enable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JMenuItem enable" Watch "JMenuItem enable" New topic
Author

JMenuItem enable

huguette santos
Greenhorn

Joined: Sep 10, 2002
Posts: 8
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

Joined: Oct 18, 2000
Posts: 4121

Hmmm... Take a look at the example code below and see if it works...



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
huguette santos
Greenhorn

Joined: Sep 10, 2002
Posts: 8
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 ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMenuItem enable
 
Similar Threads
Menu update
(Contractors) using icons and accelerate keys
JPopupMenu JMenuItem and JMenuItem : Listen to each other?
How Can I Disable Menu-Items?
Menu items disabling