问题描述:

I make a basic plugin on netbeans 8.0.2 and I'm a little confused because I want to read the code in some way to provide errors or other notifications to the user you are writing code but not how.

网友答案:

This should print out all the text in all the open windows.

TopComponent tcArray[] = WindowManager.getDefault().findMode("editor").getTopComponents();
for (TopComponent tc : tcArray) {
    System.out.println("tc = " + tc);
    Collection<? extends FileObject> fileobjs = tc.getLookup().lookupAll(FileObject.class);
    for (FileObject fo : fileobjs) {
        try {
            String text = fo.asText();
            System.out.println("text = " + text);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}

In order to use it you need the following modules added as dependencies.

File System API
Lookup API
Utilities API
Window System API

相关阅读:
Top