boolean () { if (!myCustomFocus) return super.requestDefaultFocus(); if (myComponent == null) return false; // Just in case someone requests the focus when we're already removed from the Swing tree. final JComponent preferredFocusedComponent = IdeFocusTraversalPolicy.getPreferredFocusedComponent(myComponent); if (preferredFocusedComponent != null) { if (!preferredFocusedComponent.requestFocusInWindow()) { IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(preferredFocusedComponent, true)); } return true; } return myComponent.requestDefaultFocus(); }