Pros, cons of moving from Swing to JavaFX: UI tools a plus
By Jan Stafford
In spite of JavaFX's steep learning curve, its "eye candy factor" convinced Lynden Inc. senior software architect Rob Terpilowski to leave Swing behind and use JavaFX to design rich user interfaces (UI) when building and deploying multi-platform client applications. JavaFX's main draw is its easier path to creating user effects like reflections or drop shadows, "the things that actually can give a user interface a sense of realism and depth," he said.
A steep learning curve is the price to pay for JavaFX's more modern UI options. Terpilowski recalled James Gosling saying that Swing is the 747 of UI frameworks, and flying 747s can be a little intimidating. Like Swing, JavaFX has a lot of moving pieces. Some Swing skills can be carried over, but not all. "That's why I was glad to see a lot of JavaFX sessions at JavaOne," said Terpilowski, who was co-presenter of one of those sessions, "Practical Pros and Cons of Replacing Swing with JavaFX in Existing Applications."
Things that you can do in JavaFX might be possible to do in Swing, but it would be a major, major pain to do them.
senior software architect, Lynden Inc.
The promise of future innovation in JavaFX also appealed to Terpilowski and his development team at Lynden, a transportation firm. A Java UI library, JavaFX is written as a Java application program interface (API) and can reference APIs from any Java library. While Oracle will still support Swing as a UI library, the company has promised future improvements only on JavaFX.
Terpilowski compares Swing and JavaFX, outlines the pros and cons of JavaFX and describes how his team is making the switch in this conversation, based on interviews with TheServerSide at and just before JavaOne 2013.
Is the "eye candy factor" -- the feature-rich UI tools -- the key strength of JavaFX?
Rob Terpilowski: That's a big strength, yes. The metaphors that you can create in JavaFX to represent the problem that you're trying to model and solve are really just limited by your imagination now. Things that you can do in JavaFX might be possible to do in Swing, but it would be a major, major pain to do them.
How did you introduce JavaFX to Lynden's business and development teams?
Terpilowski: For my managers, who are the project stakeholders, I developed a demo tool that looks almost like an airport arrival board. On it, the warehouse manager can see all the trips that are currently inbound to their destination, the time that they're arriving or scheduled to arrive, and what modes of transport they're arriving on: rail, ship or truck. That UI may not be the final product, but I wanted to get my team to think about the possibility of representing this data in nontraditional ways, in order to give the user a better way to interact with the application.
Is there a JavaFX weakness that gives you pause?
Terpilowski: The weakness with JavaFX? I wouldn't feel comfortable developing a Web-based application for JavaFX, just because you can't assume that the user has the framework already installed on their machine. If they don't, you don't necessarily know if the user has permissions on their machine to even download and install the latest version of Java.
I do think JavaFX is going to be the way going forward for developing desktop applications, but I'd be surprised if you see a lot of Web applications as the first projects. Maybe we'll see more FX there once Java 7 and JavaFX get out there and people get rid of their Windows XP machines. Meanwhile, I'm seeing JavaFX more as a desktop framework for developing desktop applications.
What are Swing's strengths and weaknesses?
Terpilowski: Its large developer base is a plus for Swing. Swing is still the most-used current UI toolkit.
The drawback of Swing is that it looks like there are no plans for adding any new functionality to it. The other downside is, well, that JavaFX is a nice new toolkit, with which you could do all kinds of stuff easily that you can only do in Swing with a lot of work. As momentum gains for JavaFX, I think we'll start to see more and more people switching from Swing UI to using components from JavaFX for their user interfaces.
What are some of the architectural choices that need to be made when using JavaFX?
Which development tool do you favor for UI design? Let us know your thoughts.
04 Oct 2013