Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disabling short cut keys

 
Roy Pozarelli
Ranch Hand
Posts: 51
  • 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?
 
Rob Camick
Ranch Hand
Posts: 2600
9
  • 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: 51
  • 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
Ranch Hand
Posts: 2600
9
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic