| 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.
|
 |
 |
|
|
subject: Enabling a disabled Menu Item
|
|
|