I know you can call JComponent.setFocusable(false)
to make a Java component not be focusable. But since I have a LOT of components in my application that I want to be that way, I was wondering if there is a simpler way than calling it on every one of dozens of objects. Like a UIDefaults
value?
I'm looking for this because my application runs full-screen and there is a KeyListener
on the JFrame
that listens for key strokes to trigger various events. But I found that whenever a JButton
or other added component is clicked it would get the focus and the key events would never reach the JFrame
. So a more elegant way to have key events be caught by a single parent container regardless of what child has the focus would also serve to fix my problem.