NetBeans APIs Outside of the NetBeans Platform

Jarda and I are in Budapest visiting a team of developers. Somewhere along the line, I think in the taxi on the way from the hotel to the site, he knocked together an application that uses the NetBeans APIs, without using the NetBeans Platform. In other words, there's no module here. Just a plain Java application. The end result is a file browser that looks as follows:

And this is the source structure of the application. Of course, take special note of the NetBeans API JAR files. You can easily get them from your distribution of NetBeans IDE and then simply add them to your own application:

By the way, Jarda added the beans from the org.openide.explorer.ExplorerManager JAR to the Palette, in order to be able to drag and drop the two views on the JFrame! He says that ideally the apisupport project should do that by default. Here's how it looks:


import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;

public final class FileNode extends AbstractNode {
    private File file;
    private FileNode(File f) {
        super(new FileKids(f));
        file = f;
    public static Node files() {
        AbstractNode n = new AbstractNode(new FileKids(null));
        return n;
    private static final class FileKids extends Children.Keys<File> {
        File file;

        public FileKids(File file) {
            this.file = file;
        protected void addNotify() {
            if (file == null) {
                File[] arr = File.listRoots();
                if (arr.length == 1) {
                    arr = arr[0].listFiles();
            } else {
                File[] arr = file.listFiles();
                if (arr != null) {

        protected Node[] createNodes(File f) {
            FileNode n = new FileNode(f);
            return new Node[] { n };



import org.openide.explorer.ExplorerManager;

public class Explorer extends javax.swing.JFrame implements ExplorerManager.Provider {

    private ExplorerManager em;
    /\*\* Creates new form Explorer \*/
    public Explorer() {
        em = new ExplorerManager();
    /\*\* This method is called from within the constructor to
     \* initialize the form.
     \* WARNING: Do NOT modify this code. The content of this method is
     \* always regenerated by the Form Editor.
    private void initComponents() {

        contextTreeView1 = new org.openide.explorer.view.ContextTreeView();
        listView1 = new org.openide.explorer.view.ListView();


        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
                .add(contextTreeView1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                .add(listView1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, listView1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, contextTreeView1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE))
                .add(23, 23, 23))

     \* @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Explorer().setVisible(true);

    public ExplorerManager getExplorerManager() {
        return em;
    // Variables declaration - do not modify                     
    private org.openide.explorer.view.ContextTreeView contextTreeView1;
    private org.openide.explorer.view.ListView listView1;
    // End of variables declaration                   

Finally, here's

public class Main {

     \* @param args the command line arguments
    public static void main(String[] args) {



Well, this is really cool. Probably we shouldn't be suprised, but so far the only NetBeans APIs I've talked about a plain J2SE use was the Lookup and the Visual Library. I'm going to add this for my next talk about the platform.

Posted by Fabrizio Giudici on October 05, 2007 at 01:42 AM PDT #

This is very interesting -- and timely, in light of the fact that I was discussing exactly this with some developers last week.

What I wonder is, how much of the API can you use in a regular Swing application (i.e. not as modules)? While the code is pure Java, I think that there has got to be at least some places that are dependent on being loaded as module (classloader issues) or that depend on core infrastructure (for example, maybe the Dialogs API assumes that you're running within the WindowManager class instead of simply a JFrame.

Posted by Tom Wheeler on October 05, 2007 at 03:13 AM PDT #

Hi Fabrizio and Tom. Cool to see interest in this. I'm sure thst this approach isn't possible for all NetBeans APIs, but for those where it does work, it is really cool.

Posted by Geertjan on October 06, 2007 at 07:39 PM PDT #

Geertjan- this is a perfect way for desktop java developers to migrate from using pure Swing to using the Netbeans platform in small incremental steps. Plunging into desktop app development based on the Netbeans platform is still a bit daunting for mere mortals even with excellent resources like your blog and your book. Thanks.

Posted by Bob Namestka on October 26, 2007 at 04:04 AM PDT #

I could not agree with you more, Bob!

Posted by Geertjan on October 26, 2007 at 04:06 AM PDT #

Could someone give me the project ready? please
I have problems with the code,I have no idea why.

Posted by George L. on February 23, 2011 at 08:53 AM PST #

Can you give even a small clue about what's going wrong? Otherwise you will not get any help, not from me anyway.

Posted by Geertjan Wielenga on February 24, 2011 at 06:11 AM PST #

Hi Geertjan, great article. I wonder if it is possible to also use the NetBeans Window System (TopComponent) outside the NetBeans platform, as we already have our own platform for a Swing-based desktop application. We are currently using the JIDE Docking Framwork, but we need to get rid of it. Can't find anything about this in the net.

Posted by Norman on June 05, 2014 at 05:47 AM PDT #

Norman, sent you an e-mail, hope you got it.

Posted by Geertjan on June 05, 2014 at 09:44 PM PDT #

I would be interested in using the Netbeans Window System outside the Netbeans platform too.

Is that possible?


Posted by Dan Fabrizio on October 08, 2014 at 05:17 AM PDT #

I'd advise against it. I haven't seen any applications that make use only of the NetBeans Window System. Sounds a bit like a misunderstanding of the Window System as well as the NetBeans Platform as a whole, to want to do that. Search for 'Swing docking frameworks' and you'll probably find other docking frameworks that are not tied to a comprehensive application framework like the NetBeans Platform.

Posted by Geertjan on October 09, 2014 at 07:38 AM PDT #

Hi Geertjan,

Thank you for your responses.

I have worked through your "Netbeans Visual Library Tutorial" and find it extremely helpful. My need is to have the palette functionality, but outside the IDE, as discussed in the article titled "Netbean API's outside of the Netbeans Platform". This latter example uses a browser as an example. Now to the questions:
1. Is there a tutorial on using the palette outside the IDE. If not, can the tutorial on using netbeans API's outside the Netbeans platform be used to develop the palette requirement, given the palette API qualifies for external use?

Many thanks for your contributions,

Kind regards,
Dr. Robert Lemke

Posted by Robert Lemke on December 04, 2014 at 03:16 AM PST #

No, I'm sorry, the Palette cannot be used outside of the NetBeans Platform. Too many dependencies on various NetBeans APIs. I recommend you either commit to the NetBeans Platform or recreate palette functionality in your own application from scratch.

Posted by Geertjan on December 04, 2014 at 03:21 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« March 2015