/** * Builds a list of components (Component) for a form that are ordered in the default focus order. */ public static LinkedHashSet buildDefaultFocusPolicy(FormComponent fc) { System.out.println("buildDefaultFocusPolicy form: " + fc.getId()); final FormComponent theform = fc; LinkedHashSet default_policy = new LinkedHashSet(); LayoutFocusTraversalPolicy policy = new LayoutFocusTraversalPolicy() { protected boolean accept(Component aComponent) { if (aComponent instanceof StandardComponent) { if (((StandardComponent) aComponent).getBeanDelegate() == null) return false; } if (aComponent == theform) return super.accept(aComponent); if (aComponent instanceof FormComponent) { if (((FormComponent) aComponent).isTopLevelForm()) return false; } if (aComponent instanceof JTabbedPane) return true; if (aComponent != null) { /** handle the case for embedded focus cycle roots such as JTabbedPane forms */ Container cc = aComponent.getParent(); while (cc != null && cc != theform) { if (cc instanceof FormContainerComponent) { return false; } cc = cc.getParent(); } } return super.accept(aComponent); } }; Component comp = policy.getFirstComponent(fc); Component last_comp = policy.getLastComponent(fc); while (true) { /** Don't add scroll pane in design mode since the scroll bars might not be visible */ if (FormUtils.isDesignMode()) { if (!(comp instanceof JScrollPane) && !(comp instanceof JScrollBar)) { default_policy.add(comp); } } else { default_policy.add(comp); } if (comp == last_comp) break; System.out.println("FormFocusManager.getComponentAfter: " + comp.getClass()); comp = policy.getComponentAfter(fc, comp); } return default_policy; }