aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Enabling a disabled Menu Item Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Enabling a disabled Menu Item" Watch "Enabling a disabled Menu Item" New topic
Author

Enabling a disabled Menu Item

Kelly Harris
Greenhorn

Joined: Mar 27, 2002
Posts: 22
I am using a JMenuItem and wish for it to start of disabled and based on an event for it to be enable(true). I can set the item to true but it never shows up as enabled.
I looked for a refresh but only found a repaint. The repaint did not seem to work. Please help me.
Thanks,
Kelly Harris
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
You shouldn't need to do a repaint using setEnabled(true). Are you sure your event is coded correctly? It would be easier to help if you post some of the code.
Kelly Harris
Greenhorn

Joined: Mar 27, 2002
Posts: 22
Very straight forward code but it is thrown across multiple classes. I build the JMenuItem and then disable it. Add it to a JMenuBar. Along the lines a user can do a file->open that will trigger this item to be active. I would also like to use this with Copy/Cut/Paste under an edit menu.
I put together a little snippit of code that demonstrates what I am talking about.
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
Here is your problem:

enable(true) needs to be changed to setEnabled(true)
Kelly Harris
Greenhorn

Joined: Mar 27, 2002
Posts: 22
Thank you Angela. I do not know why I used the Enable Method. So what does Enable do? From what I read it should have worked.
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
The enable method is deprecated as of version 1.1 - that's why it no longer works correctly. It has been replaced by the setEnabled method.
Kelly Harris
Greenhorn

Joined: Mar 27, 2002
Posts: 22
Thanks again Angela, you are the best.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Enabling a disabled Menu Item
 
Similar Threads
selectOneMenu rendered while it shouldn't
making GlassPane visible
Need usage help for getDocumentById
disable text box
Select the text value from a Disabled JCombobox