NOTE:
This document was prepared for NetBeans 4.1. It needs to be updated to reflect the new dialogs in NetBeans 5.0. Looking for volunteers!Purpose
This HOWTO describes the process for setting up the SwingLabs projects within NetBeans version 4.1 or later. These instructions should be applicable to previous versions of NetBeans as well, however I have not tested previous versions of NetBeans and cannot gaurantee the accuracy of this HOWTO for those prior versions.
Step 1: Getting NetBeans
The first step is to actually download the 4.1 version of NetBeans. If you have already done so, you can skip down to Step 2: Configuring CVS.
NetBeans is a fast and fully-featured Integrated Development Environment (IDE) with support for Java(TM) compliant applications for accelerating development across all major OS platforms. NetBeans.org provides an open source, high performance, modular, extensible, multi-platform Java IDE to accelerate the development of Java applications, web services and mobile applications.
Although this document is tailored for the NetBeans IDE, you should similarly be able to download, configure, and build SwingLabs projects with any major Java(TM) IDE including:
First, download the 4.1 Beta. The download is about 45MB in size, and the final product will need roughly 136MB total hard disk space. Make sure you have enough disk space, and bandwidth.
The first page you are presented with after following the above link asks you
for your platform and some information. Feel free to sign up for everything.
Or not. The choice is yours. After clicking "next", you will be presented
with several choices. For my particular platform (Slackware Linux 10.0, if
you must know) I was presented with 3 choices: with the installer, with the
Sun Application Server 8.1, or with the Mobility Pack. Since I'm doing
client side application work, I chose the first option, NetBeans IDE 4.1 Beta Installer.
After having selected your download, you will be presented with a click through license. Once the download has begun, choose a location for the downloaded file and get yourself a can/cup/bottle of your favorite beverage. If, like myself, you are fortunate enough to have broadband, you'd better consumer your beverage of choice rather quickly because the download will be done by the time you make your way to the fridge (unless you are more fortunate than myself to have a fridge next to your workstation).
The downloaded installer will be in a format correct for your platform. For
the linux download, the name of the file was netbeans-4_1-beta-linux.bin
In order to execute this file, I executed the following commands:
richb@bubs% chmod u+x netbeans-4_1-beta-linux.bin
richb@bubs% ls -l netbeans-4_1-beta-linux.bin
-rwxr--r-- 1 richb richb 47327654 2005-04-19 17:23 netbeans-4_1-beta-linux.bin*
richb@bubs% ./netbeans-4_1-beta-linux.bin
Once the file is executed (and from here the procedure is the same regardless
of your platform) you will be presented with an install Wizard. The wizard will
walk you through the installation process, so I am not going to go over the details
here. I will mention one thing that is important: be sure you have Java 5 installed
on your system before you begin the installation process. If Java 5 is not installed
now, you will have to install it later and configure your SwingLabs projects to point
to it, since SwingLabs is built on Java 5. Its easier to do it now. So go ahead,
get it.
If you are feeling adventurous, you could even go get the latest dev build of
Java 6.
NOTE: As of 19 April 2005, the build is broken under 1.6 due to a naming clash. JXTable has an isPrinting() method, and so does JComponent in 1.6. A fix is being submitted for this today, but other little issues may remain
Now you can go ahead and fire up NetBeans! In the installation directory, you will find a "bin" directory. The executable within this directory differs depending on the platform. I believe it is netbeans.exe on Windows, and simply netbeans on Linux.
Step 2: Configuring CVS
Now that NetBeans is installed and running, we're ready to configure CVS for NetBeans. These instructions are applicable if you are outside of a corporate firewall. If you are behind a firewall, you may need to setup a proxy, or do as I did and use ssh as a proxy (with a little utility called sconnect. I'm not sure if that is available on the net, you can try googling it.)
First, open the Versioning Manager. It can be found by selecting the "Versioning" menu, and then selecting the "Versioning Manager" menu item. The Versioning Manager maps a working directory to a Version Control System (VCS, not to be confused with Concurrent Versions System or CVS, which is a type of VCS!) repository. For example, a single working directory can be mapped to ALL of the java.net projects! Each project would end up being "checked out" into a subdirectory in that working directory. You would need another working directory for any projects on your own internal CVS server, or on the sourceforge CVS server, etc.
Since you don't currently have any working directories set up, click the "Add" button. You will be presented with the following dialog:
From the Version Control System Profile combo box, select "CVS" The dialog will then change to contain a bunch of fields that needs to be filled out in order to download from CVS. An example containing my information is found in the next image. Listed below are the values I entered for the various fields.
- Working Directory: /usr/local/src/javanet
- CVS Server Type: pserver
- CVS Server Name: cvs.dev.java.net
- Port: 2401
- Repository Path: /cvs
If the working directory you chose does not exist, NetBeans will not let you finish this
wizard. So, if like me your directory does not yet exist, click the Browse button in order
to browse to where your directory needs to be created, and click the New Directory button
(it might have an icon that looks like this
). Also, be sure to click
the "Login" button after setting your password. This will do two things.
First, it will ensure that your password is legitimate, and that you can connect to
the CVS server. Second, it will save that password with the working directory, so that
for future CVS commands on files within that working directory you won't have
to type in your password again.
We're now ready to click the Next button, and perform our checkout. If you are new to CVS it may be worth your time to become familiar with CVS terminology. The defacto standard CVS documentation is called the Cederqvist in honor of its original author, and can be found here. http://www.cvshome.org maintains a FAQ and other useful documentation as well.
What we want to do is to check out several modules from java.net. These modules corrospond to the SwingLabs projects. In fact, in java.net there is a one-to-one corrospondance between project names and module names. So, to checkout the databinding.dev.java.net project, you would check out the databinding module. As you can see from the screenshot, by listing several modules I can have CVS check out several modules at the same time. To make our life easier (and this HOWTO shorter), that's what we'll do. After entering the modules names (separated by a space) into the Modules text field (and ensuring that Modules radio button is selected!), you can safely click Finish. You will soon see a bunch of messages in the VCS Output tab in NetBeans. Be patient, there is a lot of code (and jars!) to check out!
Step 3: Building SwingLabs
The section heading title "Building SwingLabs" is somewhat of a misnomer. In order to build all of the SwingLabs projects together, you'd really want to checkout the swinglabs module and execute an as-yet-undefined build target, such as "ant build-all". However, since SwingLabs provides regular bi-weekly builds of all of the SwingLabs projects, that isn't very useful for the average developer. Rather, you are probably interested in hacking on a specific project, or building a specific project. Hence, what this section is really all about is getting the project setup so you can hack on the sources.
This step is really, really simple. Click the little open folder icon, or select File|Open Project (or, to really confuse those coming from Eclipse, you can hit ctrl-shift-o). Navigate until you find /usr/local/src/javanet/swinglabs-demos (or whereever your swinglabs-demos project was checked out to). Select that project. You will notice that the Open Project dialog contains two check boxes: Open As Main Project, and Open Required Projects. Make sure Open Required Projects is selected. You should also see three required projects: databinding, swingx, and jdnc. Click the Open Project Folder button. All four projects should now be opened in your Projects tab!
In order to build a project, you right click on the project's root node and select Build Project. Go ahead and perform a "Clean and Build" on the swinglabs-demos project. You will notice that not only is the swinglabs-demos project compiled, but its dependencies (databinding, swingx, and jdnc) are also compiled! Now, expand the source package structure on swinglabs-demos until you find org.jdesktop.demo.swingx.SwingXDemo. Right click on that file node, and select "Run File". You should see the SwingXDemo run. Similarly, you could set a breakpoint in the file and select "Debug File".
That's all there is to it. Have fun hacking!
Notes and Addendum
Based on user submitted feedback, you MUST use NetBeans 4.1 to follow these examples. To use with NetBeans 4.0, you'd have to recreate the project files, aparently. The project files in CVS are 4.1-compatible and won't load properly in 4.0, apparently