Over a million developers have joined DZone.

JavaFX Script vs. Swing: Are You Still Concerned?

DZone's Guide to

JavaFX Script vs. Swing: Are You Still Concerned?

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

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: <<net.java.javafx.ui.XButton>>;

//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 :-).

From: blog.adam-bien.com

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}