Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Disabling short cut keys

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • 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: 3191
29
  • Mark post as helpful
  • send pies
  • 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
  • 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: 3191
29
  • Mark post as helpful
  • send pies
  • 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.
 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic