Java Champion / JavaOne Rockstar Adam Bien ( is a self-employed consultant, lecturer, software architect, developer, and author in the enterprise Java sector. He is also the author of several books and articles on Java and Java EE technology, as well as distributed Java programming. adam has posted 59 posts at DZone. View Full User Profile

JavaFX Script vs. Swing: Are You Still Concerned?

  • submit to reddit
The concerns about the future of Swing and it's relation to JavaFX seem to be all over the place right now. However—if you look under the hood of JavaFX Script—all the widgets seem to wrap/need Swing components more or less directly. JavaFX Script seems to use Swing components as "Service Provider".

Some JavaFX samples (the declaration inside << >> refers to Java classes):

//JavaFX Button
public class Button extends Widget, RotatableWidget, ActionWidget {
private attribute button: <<>>;

//JavaFX Dialog
public class Dialog extends AbstractFrame {
private attribute jdialog:<<javax.swing.JDialog>>;

//JavaFX Script Frame
public class Frame extends AbstractFrame {

private attribute winListener: <<java.awt.event.WindowListener>>;
private attribute compListener: <<java.awt.event.ComponentListener>>;
private attribute frame: <<javax.swing.JFrame>>;
[I copied the samples from the NetBeans 6.0 JavaFX Plugin.]

The relationship between JavaFX Script and Swing is similar to the relationship between Swing and AWT or JFace and SWT: JavaFX Script is a decorator of Swing components.

However, JavaFX Script allows the usage of Swing components in a declarative way (without the setter-style) and in that way simplifies Swing development. From my perspective, JavaFX Script can be considered as a Domain Specific Language which compiles to Java 2D/Swing. With JavaFX Script, the development of Swing components becomes more fluent and object oriented... so that it is a nice complement and not a substitution. It is much easier to pimp up Swing apps with JavaFX with some visual effects.

I'm actually less concerned with the future of Swing: during the JavaONE 2008 technical sessions enough exciting, Swing related stuff was presented (JWebPane, Scene Graph, Java 6 update 10, Applets / WebStart etc.). ...and all cool IDEs like IntelliJ/NetBeans IDE are Swing-based :-).


Published at DZone with permission of its author, adam bien.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Mikael Grev replied on Tue, 2008/05/27 - 1:50pm

> JavaFX Script vs. Swing: Are You Still Concerned?

Yes I am. A new layer is seldom a good thing even if it looks that way to an architect. Win32-> MFC, AWT -> Swing are two examples of something that does not work really well when it comes to actual API usage. .NET and WinForms got it kind of right though, there you seldom need to go down to the layer below to do something.

I also want to question the "Declarative is better" opinion that all seem to cluster around. Declarative is not better, it is just different. Better for some things and worse for other. Static GUIs: good. Dynamic GUIs: not so good. Static with bound content: good. Dynamic with bound content: not good at all.

In all I am worried, but hopefull.

JavaFX IS good in that it has brought us the new Plugin, Direct 3D 9 hw acceleration, translucent and shaped windows, Java Kernel, Java Startup Cache (even if the highly visible gutter Icon shows that they still not really understand the customer..) and much more. I do not think that would have been done if not for JavaFX. It is just the JavaFX Script part I see no real need for. I can see other ways to solve the problems it is set out to solve.

Mikael Grev

Kevin Daly replied on Tue, 2008/05/27 - 7:39pm

I'm not concerned, JaxaFX is a great idea, I only hope it is not too late. Flex and Silverlight have both released product. The issue is that we still haven't seen the whole FX stack, if Sun can deliver this soon, they can leverage the fact that they have the best VM and if the new plugin performs as promised, we will have a  Renaissance in Java Applets.

People only seem to evaluate FX on the scripting language, they don't seem to realize that the FX strategy is enhancements to the JRE as well. These enhancements (Scenegraph etc etc) will benefit the community greatly. 

Romain Guy replied on Wed, 2008/05/28 - 11:27am

>> new Plugin, Direct 3D 9 hw acceleration, translucent and shaped windows, Java Kernel

These have nothing to do with Java FX and were started/planned before the JavaFX craze.  

Mikael Grev replied on Wed, 2008/05/28 - 11:34am in response to: Romain Guy

That might be so, but they are touting it as a thing JavaFX brought.. (since JavaFX is a campain to enhance Java on the desktop). It can also be that they decided to put in a lot of effort to fix the desktop and then, later, named it and made it a marketing thing.

Anyway, the "desktop push" that now is called JavaFX brings these good things.

Mikael Grev replied on Wed, 2008/05/28 - 11:35am in response to: Mikael Grev

Btw, Romain, what is your take on JavaFX Script?

Romain Guy replied on Thu, 2008/05/29 - 5:13am

JavaFX got me very excited a year ago but not so much nowadays. First of all, I like the language's features but I find that some of them might make understanding source code more difficult (binding of arbitrary expressions/variables/etc. for instance.) Then I don't find JavaFX scripts particularly clear or easy to read. Finally, and more importantly, the promised designer tools are still nowhere to be found and if I don't have them, I don't care about JavaFX *at all*. I'm sure this will change, but *right now*, I am not interested in FX. I'm much more attracted to Flex and Silverlight (I really like Flex's approach to build bits of the platform in your apps, thus allowing the platform to change a lot from one version to another.)

Michael Azzi replied on Thu, 2008/05/29 - 1:06pm in response to: Romain Guy


JavaFX got me very excited a year ago but not so much nowadays. First of all, I like the language's features but I find that some of them might make understanding source code more difficult (binding of arbitrary expressions/variables/etc. for instance.)


I would like to comment on this particular point from your post, i.e. the fact that binding makes things more difficult to understand. I am not sure what you mean here, but having used JavaFX for a while now, I tell you I would take this hidden, and maybe even mysterious magic of binding and whatever surprises if might throw at me, I would take it any day over the pain of having to do all the wiring, and plumbing for my UI otherwise. You see, I am not, and most of us are not Romain Guys and Mikael Grevs, and we could really use a little help in developing our UI apps, in exchange for a little less control over how things are being done. But I can understand how you on the other hand, might not find that particularly interesting. That's the beauty of declarative style programming, and why I think it's a boon for developer's productivity. You simply declare what you want to have done, and let the system figures out the how it getting done.

Romain Guy replied on Fri, 2008/05/30 - 1:31pm

Don't get me wrong, I really really like the bindings. I'm just saying that I find it awesome... as long as I am the one writing/reading the code :)

Dmitri Trembovetski replied on Mon, 2008/06/02 - 7:06pm in response to: Romain Guy

> These have nothing to do with Java FX and were started/planned before the JavaFX craze.

Not entirely correct. They may have been planned for 7 by there's no way they would have made it into 6u10 without the push from the FX side. This is at least true for translucent/shaped windows, vsync BufferStrategy support, the new D3D pipeline. Dmitri

Java Guy replied on Wed, 2008/06/04 - 4:18am

I agree w/ Romain.  No tools = no chance.  Adobe has and will continue to provide integration w/ Flash, Creative Suite etc.  MSFT has expresssion tools.  Designer's aren't going to touch JavaFX unless Sun or someone starts providing these tools.

For old swing hands, there is almost no compelling reason to build on JavaFX as opposed to normal swing.

Kevin Daly replied on Wed, 2008/06/04 - 6:35am in response to: Java Guy

The tools are coming. Sun is working on a designer tool, as well as tools that integrate with Adobe products.

As far as old swing hands, JavaFX is not targeted at  you, it's targeted at the designer (Although it's binding is really quite usefull).

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.