FeaturesPluginsDocs & SupportCommunityPartners

Working with the Open Sourced Swing Sources

The sources in the Swing project address the all-Java Swing user interface components. In this tutorial, we examine the Swing project in the IDE and learn what we can do with it.

When encountering problems of any kind, please consult the Troubleshooting Guide.

Setting up

Download and install the OpenJDK sources, and then open the Swing project, as explained in Getting Started with OpenJDK in NetBeans IDE.

Once you have opened the project, the Projects window should look as follows:

Swing in projects window

Building the Swing Sources

To build the Swing sources, right-click the Swing project in the Projects window and choose Build Project. The IDE runs the Ant script for the project and shows output in the Output window.

To view the build results, go to the Favorites window (Ctrl-3) and browse to the "j2se" folder. Once you have added the folder, you can see the newly created "build" and "dist" folders, the latter containing your build output, as shown in the following image:

javac project build outputs

Running the Swing Demo

Whether or not you build the Swing sources, you can explore the SampleTree demo, shown below in the Projects window:

Swing demo

Run the demo by right-clicking the Swing project in the Projects window and choosing Run Project. The IDE runs the Ant script for the project and deploys the demo:

Swing demo running

Generating Swing Javadoc

When you want to access Swing programmatically, you can do so via the Swing APIs. Before you do so, you can generate the Swing Javadoc. Right-click the Swing project and choose Generate Javadoc for Project. The IDE's browser appears, displaying the generated Javadoc:

JConsole running

In the Favorites window (Ctrl-3), you can browse to the Javadoc files, which are generated to the j2se/build/${platform}/javadoc/swing folder, as shown below:

Javadoc sources

Companion
Projects:
MySQL Database Server   Open JDK: an Open SourceJDK   GlassFish Community: an Open Source Application Server    Mobile & Embedded Community    Open Solaris   java.net - The Source for Java Technology Collaboration   Virtual Box - full virtualizer  Open ESB - The Open Enterprise Service Bus Powered by