JComponent () { if (myPreferedFocusComponent != null) return myPreferedFocusComponent; FocusTraversalPolicy focusTraversalPolicy = null; Container container = myCenterPanel; while (container != null && (focusTraversalPolicy = container.getFocusTraversalPolicy()) == null && !(container instanceof Window)) { container = container.getParent(); } if (focusTraversalPolicy == null) return null; Component component = focusTraversalPolicy.getDefaultComponent(myCenterPanel); while (!(component instanceof JComponent) && component != null) { component = focusTraversalPolicy.getComponentAfter(myCenterPanel, component); } return (JComponent)component; }