Search code examples
javaswingjgoodies

how to handle focus lost and focus gain event using "shift + tab" and "tab"?


I want the ability to gain the focus on the next focusable component on clicking tab and to get the focus back on the previous component on shift + tab. So need a help on how to achieve the same. thanks


Solution

  • Unless I misunderstand your question, what you describe is the default behavior of java Swing on Windows and probably on Linux too. Mac OSX handles tab focus a bit differently (not all elements are reachable by default).

    If you want to customize the keyboard focus order and things like that, the default API to do that is via java.awt.KeyboardFocusManager.