Skip to main content

SwingLabs and Swing

Posted by rbair on August 12, 2005 at 1:25 PM PDT

In my last blog's comments Andy Roberts asked the following question:

I always keep my eye on SwingLabs because it is adding great value to the existing Swing toolkit. One thing that confuses me is just *how* it interacts with Swing, within the development process, that is. SwingX is an incubator for neat features, for example, sortable tables. Yet the approach adopted by Swing devs in Mustang is different than that in SwingLabs. And license issues seem to be contradictory, with SwingLabs being LGPL, it can't ever be absorbed into the main Java code. I've personally communicated to Richard discussing this, but it would be worthwhile clarifying fully the interaction between Swing and SwingLabs for all.

The Short Answer

SwingLabs is simply an incubator for ideas that can be incorporated into Swing. Swing engineers work on both Swing and on SwingLabs (incidently, SwingX contributors include Scott Violet who is the Swing architect, and Josh Outwater who is a Swing engineer for Apple, as well as several other Swing engineers).

The Long Answer

There is a real need in the desktop java community for components and frameworks to aid in writing rich client Swing applications. This need is deeper than simply updating the Swing toolkit. Things such as a data binding framework, application framework, tool support, progress management, and so on are really not part of the Swing toolkit per se. Rather, they are built beside or on top of Swing to help make the Swing application programming experience better.

There are also many things which are directly related to Swing, such as our JXTreeTable component. Another example is the filtering, sorting, and highlighting support for trees, tables and lists. The JXDatePicker is another good example. Work on these components is directly related to the Swing toolkit.

This is a minor distinction that substantially alters the way that SwingLabs interacts with the JDK. Frameworks built around the Swing toolkit that are included in the JDK will go through a formal JSR process, while additions to the Swing toolkit itself will be done via one of the release JSRs (such as the JSR for Dolphin). This is more a matter of procedure, but is a good thing to keep in mind.

As I mentioned in the "Short Answer", SwingLabs was initially created as an incubator for Swing. It was a place that Swing engineers could test out proposed enhancements with the community. It's LGPL license ensured that any changes to the code would have to be publicly available, while also allowing developers to bundle the code with their proprietary applications.

But it didn't take long to notice that developers wanted to build Swing apps now and couldn't wait 18 months or longer for these changes to be made available in the JDK. I was one of those developers. Helping rich client Swing applications take root is a very important goal for the SwingLabs project.

If the project is LGPL, then how can it be incorporated in the JDK?

This is a legal question more than a techinical question, but I'll do my best to answer it with the general caveat that I am not a lawyer. However, as I understand it, when you write a piece of code there are two different kinds of rights that you get. The first is copyright. Copyright means that you own what you wrote the instant that you wrote it, and you have the right to do with it as you please. One of those rights is to assign a license to your work. The License dictates what rights others have with your work. However, as the copyright owner you have the right to be able to change the license at any time.

So, if a Sun engineer writes some code for the SwingLabs project, then Sun (who is paying the Engineer) owns the copyright for the code. It is licensed under the LGPL, but whenever Sun decides to change license we are free to do so, since we own the copyright on the code. What was originally released as LGPL is still LGPL, meaning that it is impossible for Sun to revoke your rights to the code that was released under the LGPL, but they can dual license the code.

What does this mean for the JDK? Well, it means that in order to migrate code from SwingLabs into the JDK we need to fork the code, change license, and put the new code into the JDK. Because Sun owns the copyright, Sun can do that

However, what happens if code is contributed from folks outside of Sun? In that case, there are a couple of concerns. First, as demonstrated above, in order for SwingLabs to fulfill it's mission as an incubator for Swing Sun must own the copyright, or the code could never be included in the JDK. However, since nobody would want to hand over copyright to their own work, we use a Joint Copyright Agreement for the SwingLabs project. The JCA grants joint copyright between you the contributor and Sun. You still maintain every right you once had, but you also grant Sun copyright ownership.

In this way, Sun is able to migrate code from the SwingLabs projects into the JDK.

If SwingLabs is an incubator, then why does the implementation differ between Mustang and SwingLabs?

In an ideal world, it wouldn't. Ideally new features would be implemented in SwingLabs first, and then simply included in the JDK rather than being rewritten. Unfortunately, due to time constraints this was not fully realized for Mustang.

Can SwingLabs be used with my proprietary application?


Well, that's it for today. If you have any more questions, I'd be happy to answer them as best I can!

Related Topics >>