void (KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_LEFT) { int index = myTabs.getIndexOf(myInfo); if (index >= 0) { e.consume(); // Select the previous tab, then set the focus its TabLabel. TabInfo previous = myTabs.findEnabledBackward(index, true); if (previous != null) { myTabs.select(previous, false).doWhenDone(() -> myTabs.getSelectedLabel().requestFocusInWindow()); } } } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { int index = myTabs.getIndexOf(myInfo); if (index >= 0) { e.consume(); // Select the previous tab, then set the focus its TabLabel. TabInfo next = myTabs.findEnabledForward(index, true); if (next != null) { // Select the next tab, then set the focus its TabLabel. myTabs.select(next, false).doWhenDone(() -> myTabs.getSelectedLabel().requestFocusInWindow()); } } } }