JPanels in a JFrame. How to make a JFrame listens to a keystroke in a JPanel ?
posted 11 years ago
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.