• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Enabling a disabled Menu Item

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is your problem:

enable(true) needs to be changed to setEnabled(true)
 
Kelly Harris
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again Angela, you are the best.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic