Oracle Blog

Random NetBeans Stuff

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:

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.

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.

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.

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.

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.

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?

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.

About

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.