• Post Reply Bookmark Topic Watch Topic
  • New Topic

Key Binding not working when child component has focus  RSS feed

 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to all Ranchers,

What i want to achieve is even if a component say for example JTextField has focus which is contained in a JPanel ,the JPanel should be able to listen for KeyBindings. Right now whenever the focus goes to JTextField or any component for that matter my KeyBinding code is not working. I want to use Escape key to close the window .Here is the code i have written :
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use one of the getInputMap()'s that take an argument
getInputMap(...)
 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Michael....
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!