File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Disabling short cut keys Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Disabling short cut keys" Watch "Disabling short cut keys" New topic
Author

Disabling short cut keys

Roy Pozarelli
Ranch Hand

Joined: Oct 17, 2009
Posts: 41
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?


OCP Java SE 6 Programmer,
OCM Java SE 6 Developer
OCE Web Components (OCEWD)
OCE JPA 6 (OCEJPAD)
OCE EJB 6 (OCEBCD)
OCE Web Services (OCEWSD)
MySQL Certified Administrator & Developer,
OMG Certified UML Prof. Fund., Int., Adv.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2215
    
    7
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

Joined: Oct 17, 2009
Posts: 41
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

Joined: Jun 13, 2009
Posts: 2215
    
    7
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Disabling short cut keys