javaswingshortcutkeystroke

Application wide keyboard shortcut - Java Swing


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?


Solution

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

    KeyEventDispatcher