Swing still runs a lot of serious desktop software, and it is not going away tomorrow.
But after a week living in JavaFX 1.3 land, I am convinced these scenes and bindings deserve a seat on our desktops.
Why JavaFX for desktop apps right now
Oracle now owns Sun and the Java story is getting rearranged, but JavaFX quietly shipped some real gains. The scene graph model feels natural for UI work where you animate, fade, and move nodes instead of hand wiring paint calls. Binding cuts a ton of glue code that we usually drop into Swing models and listeners. Timeline animations are a joy for micro interactions like button pulses or progress whispers. CSS styling is not full web CSS, yet it is already better than fiddling with UIManager keys. With NetBeans 6.9 the preview is good enough to trust while you sketch, and the runtime in 1.3 is snappier than the first cut. If you build desktop apps that need polish, this toolbox is worth opening.
Data binding and animation in JavaFX Script feel like the missing link between model and pixels. This tiny sample drives itself without listeners all over the place:
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
var counter = 0;
Stage {
title: "FX Beyond Swing"
scene: Scene {
width: 320
height: 120
content: [
Text {
x: 20, y: 60
fill: Color.DODGERBLUE
font: Font { size: 24 }
content: bind "Clicks: {counter}"
}
]
}
}
Timeline {
repeatCount: Timeline.INDEFINITE
keyFrames: [
KeyFrame {
time: 1s
action: function() { counter++; }
}
]
}.play();Going beyond Swing without throwing it away
Many teams cannot rewrite a mature Swing app, and that is fine. The bridge goes both ways. You can place Swing inside JavaFX using javafx.ext.swing.SwingComponent, or embed JavaFX in Swing with JFXPanel for measured upgrades. This lets you replace one gnarly panel with a smooth chart or a skinnable control without touching the rest. Be mindful of the event threads since you now have the Swing EDT and the JavaFX thread living together. Keep heavy painting off the path and batch state changes to avoid jitter. Start small and ship something the team can feel on day one.
Wrapping a Swing button inside JavaFX is a one liner, which is perfect for gradual migrations:
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.ext.swing.SwingComponent;
import javax.swing.JButton;
var jb = new JButton("Swing says hi");
Stage {
title: "Swing inside FX"
scene: Scene {
width: 300, height: 120
content: [ SwingComponent.wrap(jb) ]
}
}Tooling, deployment, and the tradeoffs
The control set in core JavaFX is still thin, but projects like JFXtras are filling gaps fast. Styling through JavaFX CSS is simpler than UI defaults and it keeps designers and developers speaking the same language. Packaging with Web Start or the browser plugin is straightforward, and for desktop users that means click to run with caching. Watch your JAR count and image sizes since first start time sells or sinks trust. Compared with Flash or Silverlight, you trade instant plugin ubiquity for a strong Java stack and plain Java interop. For rich desktop apps that want animation, data binding, and a cleaner UI story than raw Swing, JavaFX already pays its rent.
If Swing is the toolbox, JavaFX is the sketchbook where desktop apps finally feel designed.