void (ActionEvent e) { KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Container container = kfm.getCurrentFocusCycleRoot(); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { FocusTraversalPolicy policy = container.getFocusTraversalPolicy(); if (policy == null) { policy = kfm.getDefaultFocusTraversalPolicy(); } Component next = myMoveDown ? policy.getComponentAfter(container, PaletteGroupComponent.this) : policy.getComponentBefore(container, PaletteGroupComponent.this); if (next instanceof PaletteItemsComponent list) { if (list.getModel().getSize() != 0) { list.takeFocusFrom(list == myItemsComponent ? 0 : -1); return; } else { next = myMoveDown ? policy.getComponentAfter(container, next) : policy.getComponentBefore(container, next); } } if (next instanceof PaletteGroupComponent) { IdeFocusManager.getGlobalInstance().requestFocus(next, true); } }); }