Code to get all TopComponents and EditorPanes in netbeans

Code to get all TopComponents and EditorPanes in netbeans

2017/09/16 Netbeans 0

Code to get all TopComponents in netbeans, here is very useful linkĀ http://wiki.netbeans.org/DevFaqGetOpenEditorWindows

Set < TopComponent > comps = TopComponent.getRegistry().getOpened();
for (TopComponent tc: comps) {
    ModuleLib.log("tc=" + tc);
    Node[] arr = tc.getActivatedNodes();
    if (arr != null) {
        for (int j = 0; j < arr.length; j++) {
            EditorCookie ec = (EditorCookie) arr[j].getCookie(EditorCookie.class);
            if (ec != null) {
                JEditorPane[] panes = ec.getOpenedPanes();
                if (panes != null) {
                    ModuleLib.log("panes=" + panes);
                }
            }
        }
    }
}