Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Remove key bindings from all JButtons  RSS feed

 
Heidi Koester
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
In our application, we want to remove the keybinding which allows the Spacebar to act as a mouse click on the focused button. That is, by default, hitting Space will 'click' on the focused button. We want to change this behavior so that hitting Space does not act as a mouse click.

We have figured out how to do this for individual buttons within application, e.g.:



But it seems cumbersome to do this for every single button in the application.

Is there a way to make a blanket change to the inputMap that will affect all JButtons in the application?

I experimented with this:
to see if I could affect every component within the main container. But it didn't work.

Thanks for your help.
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enter Key and Button shows how to add the Enter key globally to activate the button.

I've never tried it, but you should be able to use the same concept and update the focusInputMap to remove the space bar actions.

Note, you will need to update two actions, the pressed and released action.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!