• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanels in a JFrame. How to make a JFrame listens to a keystroke in a JPanel ?

 
Rafael March
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everybody,

I have a problem. In some part of my application, I have a screen that is a JFrame with some JPanels, like views. The point is: in one of the JPanels I have a JButton "search". I have registred a keyStroke Ctrl+F for opening the dialog of search in this view, and it works fine.

But, only when this view has the focus that the Ctrl+F works, of course. I would like that it works whatever is the JPanel that has the focus.

This would be easy. But, I'm talking about a system that any of these views knows each other. The class that implements the search is an inner class from the JPanel that has the JButton.

So, the question is that I can't have the others JPanels to get the button from the view that has it. I would like to implement a keystroke that works for all the views in my JFrame, only changing the code of the JPanel that has the search button.

Is this possible ?

Thx everybody !
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are talking about it a global keylistener. We've talked about this before.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!