TreeModel (Component c, boolean accessibleModel) { Component parent = null; if (accessibleModel && (c instanceof Accessible)) { Accessible axComponent = c.getAccessibleContext().getAccessibleParent(); if (axComponent instanceof Component) { parent = ((Component)axComponent); } } else { parent = c.getParent(); } while (parent != null) { c = parent; //Find root window if (accessibleModel && (c instanceof Accessible)) { Accessible axComponent = c.getAccessibleContext().getAccessibleParent(); if (axComponent instanceof Component) { parent = ((Component)axComponent); } else { parent = null; } } else { parent = c.getParent(); } } return new DefaultTreeModel(ComponentNode.createComponentNode(c, accessibleModel)); }