tags:

views:

346

answers:

3

Swing is good in many ways, then why do we need JavaFX?

+6  A: 

There is both a technology part of JavaFX that will help design UIs, and a language part that will make writing UIs easier.

The JavaFX technology brings a 2d scenegraph and video capabilities. Afaik these will also be made available generally to java. They are good advancements for creating client side application with fancy and interactive graphical UIs. The 2d scenegraph should make it possible to create more graphic heavy applications that are still responsive.

The JavaFX language is a much better way off creating UIs programatically. Java Swing code can get very verbose, while the same JavaFX code will be smaller and easier to maintain. Closure support makes creating event handlers easier. Declerative assignment of settings makes configuration of elements easier. Native list syntax makes adding components easier.

Please note that I haven't really written any JavaFX, but I have read code and paid attention to what's going on. I recommend trying it yourself to find out what's cooking.

Staale
I am not sure that "fancy GUIs" is what business enterprises need. In my company we develop enterprise apps (in various technologies, Java/Swing is one of them) and I don't see how we would develop equvalent apps with JavaFX.
jfpoilpret
"Swing code can get very terse": I don't think "terse" is the word you want there--just the opposite, in fact. Verbose, maybe? Or bloated?
Alan Moore
Verbose was what I meant. English is my 2nd language, I am permitted to have some tismakes :)
Staale
+1  A: 

It is the same reason why we have Java, C++, C#, Python, Perl, Ruby... although we already have C.

artificialidiot
+4  A: 

I think Staale's answer is a good start but I would add...

Use JavaFX if

1) If you're interested in developing the application for mobile or TV (note this has yet to be released)

2) If you're working with a graphic designer who is creating the appearance of the application in photoshop and you want to be able to import their look directly.

3) If making the GUI filthy rich is important to you. (so if you want a panel to fade in or out, or slide upon demand)

Use Swing if

1) You're creating an application mainly for the desktop.

2) Performance matters and you know what you are doing (so if you're writing an IDE, Swing would be a better choice)

3) You're looking for a RPC (rich client platform) to build upon.

Hayden Jones