Application wide keyboard shortcut - Java Swing

java, keystroke, shortcut, swing

Solution

Install a custom KeyEventDispatcher. The KeyboardFocusManager class is also a good place for this functionality.

KeyEventDispatcher

Problem

I would like to create an application wide keyboard shortcut for a Java Swing application. Looping over all components and adding the shortcut on each, has focus related side effects, and seems like a brute force solution. Anyone has a cleaner solution?

Original source