• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Disabling short cut keys

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my application I have a menu bar and a tool bar that use short-cut keys (CTRL-X, CTRL-B, ...). I'm using setEnabled(true/false) on my JFrame window to enable/disable mouse input. I've also looked at using a glass pane to intercept the mouse events but this seems like more code. Is there an equivalent for the keyboard input (short-cut keys) that will enable/disable all the short-cuts?
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is there an equivalent for the keyboard input (short-cut keys) that will enable/disable all the short-cuts?





However, the menus will still be painted as if enabled. You can loop through all the menus and invoke



so the menus actually look disabled.
 
Roy Pozarelli
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I used just the

then I could still invoke the menu items actions with the keyboard accelerators.

If I used just the

for each menu item then I could still invoke the menu items actions with the keyboard accelerators.

BUT if I used both at the same time, then it does inhibit the keyboard accelerators which is what I was after.

WHY is this?



Is using those 2 statements adding to 2 different action maps and/or 2 entries in a single action map?
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
menuBar.setEnabled( false ); worked fine for me on XP using JDK6.7, which is why I suggested it.

If yours doesn't work it could be a version/platform difference.

Post your SSCCE demonstrating the problem.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic