aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Java GUI - what to choose - Swing, JSF, JavaFX, other? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java GUI - what to choose - Swing, JSF, JavaFX, other?" Watch "Java GUI - what to choose - Swing, JSF, JavaFX, other?" New topic
Author

Java GUI - what to choose - Swing, JSF, JavaFX, other?

Andy Jack
Ranch Hand

Joined: Nov 22, 2012
Posts: 257
I saw a post by William P O'Sullivan which says that Swing is being replaced by JavaFX and JSF.
Which one is better for GUI in terms of technical superiority and ease of learning ?


Java Newbie with 72% in OCJP/SCJP - Super Confused Jobless Programmer.
I am a "newbie" too. Please verify my answers before you accept them.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Swing, JavaFX and JSF are three very different presentation layers.

Swing is a desktop application presentation layer - the GUI for an application running on your computer.

JSF (Jave Server Faces) is a layer for web-applications. You put it on top of JSPs and create a rich web experience using JavaScript to interact with the page. You only use it when your application is on a server, not the desktop. You don't get nearly the 'richness' of a desktop application.

JavaFX is a presentation layer somewhat akin to Flash. It is meant to be embedded in a web page. It is not a desktop application approach. It could be used instead of JApplets, for example, or possibly as an alternative to some applications delivered through Java Web Start.

In short - JSF and JavaFX are not replacements for Swing. You pick the technology for type of application you want to run. If you are considering Swing, then forget about JSF because there is zero overlap. If you are considering Applets then think about JavaFX. If you are thinking desktop, use Swing.

If you are looking to learn one and not the others... then your mind is in the wrong place. Learn one (probably Swing first if you are a new user), then another (probably JavaFX because it will be the easiest transition), and the web applications (Servlets, JSPs, JSF, and EJBs).


Steve
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2596
    
    9

I agree with Steve here. From my understanding, JavaFX is one technology that can run on both desktop (like through web start) and embed within web pages (like applets). Yet the functionalities for each technology is something you want to look at depending on exactly what user behavior you want.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Andy Jack wrote: Swing is being replaced by JavaFX and JSF.


Don't believe in that rumor! Have you seen anywhere in which Oracle declares that it is replacing Swing by JavaFX and JSF?


PM Me If You Want to get Urgent Help on Java Programming
Steve Myers
Ranch Hand

Joined: Dec 08, 2012
Posts: 47
Nam Ha Minh wrote:
Andy Jack wrote: Swing is being replaced by JavaFX and JSF.


Don't believe in that rumor! Have you seen anywhere in which Oracle declares that it is replacing Swing by JavaFX and JSF?


JavaFX replacing Swing

6. Is JavaFX replacing Swing as the new client UI library for Java SE?
Yes. However, Swing will remain part of the Java SE specification for the foreseeable future, and therefore included in the JRE. While we recommend developers to leverage JavaFX APIs as much as possible when building new applications, it is possible to extend a Swing application with JavaFX, allowing for a smoother transition.
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Hi Steve,

Thanks a bunch for the proof. So I need to change now.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39834
    
  28
I think this thread would fit better in the GUIs forum. Moving.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1089
    
  10

JSF is obviously not a replacement for Swing.

However, as pointed out above, Oracle recommends development of desktop applications using JavaFX 2.x rather than Swing. It's a different matter that JavaFX can be packaged to run in a web application (like Flash/Applet).
Basically, the idea is to have the same codebase which can run in different devices (Desktop, Browser and maybe mobile devices tomorrow).

Having said that, JavaFX is not yet tightly integrated with Java. Suppose, you develop a Swing application and distribute it, users just need the JRE for the app to run. However, in case of a JavaFX application, users need to install an extra JavaFX plugin for the application to run - note that this is true even for desktop applications.

Last heard, Oracle is planning tight integration of JavaFX with Java from version 8 onwards (so, if user has JRE 8, that would be good enough). So, at a practical level, it will take some more time for people to start using JavaFX for production-ready applications (plus the Mac/Linux versions for JavaFX were also released only recently). So, from a skills perspective, for desktop, Swing will still be used in real projects.
In the meantime, to ease the transition, both JavaFX and Swing support inter-interoperability - for example, Swing provides a JFXPanel with which you can embed JavaFX stuff within a Swing application.

So, I think it would be better to start with Swing and learn the basics - layouts, event handling will be similar in Swing and JavaFX. Nevertheless, if you are only looking at learning to code a desktop application (and not from a sole job perspective), you can start learning JavaFX 2.x.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

Ranganathan Kaliyur Mannar wrote:JavaFX is not yet tightly integrated with Java. Suppose, you develop a Swing application and distribute it, users just need the JRE for the app to run. However, in case of a JavaFX application, users need to install an extra JavaFX plugin for the application to run - note that this is true even for desktop applications.

Last heard, Oracle is planning tight integration of JavaFX with Java from version 8 onwards

Version 7u6 onwards. From Java SE 7 Update 6 Released:
Java SE 7 Update 6 provides the merging of JavaFX into the Oracle Java SE installation. JavaFX was a stand-alone product, and is now fully integrated in this release. On Windows, JavaFX and Java Access Bridge are now installed as part of the JRE or JDK. This provides convenience for end users and system administrators, who don't need to install and maintain JavaFX separately. Application developers can also be assured that from now on, JavaFX runtime libraries will be present on millions of desktops by default.


From Java SE Downloads:
JavaFX 2.2.4 is now bundled with the JDK on Windows, Mac and Linux x86/x64.


luck, db
There are no new questions, but there may be new answers.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1089
    
  10

Darryl Burke wrote:Version 7u6 onwards. From Java SE 7 Update 6 Released:

Cool. Sooner is better.

Darryl Burke wrote:From Java SE Downloads:
JavaFX 2.2.4 is now bundled with the JDK on Windows, Mac and Linux x86/x64.

Cooler!
Thanks for the info!
Jay Orsaw
Ranch Hand

Joined: Jun 14, 2011
Posts: 356

Steve Luke wrote:It is not a desktop application approach.


I agree with everything you said except for this. You can use it for desktop, the web, and soon mobile. Scene Builder is already set up with Zoom, Swipe, and Touch, and they say it will work with sensor detection as well in the future. At the last JavaOne they showed Fx on Mobile.


As to the OP I believe like Steve said, you should do Swing first, and get your feet wet, then goto FX. I have been using swing for a few years and now I am switching everything to FX. FX has so many more capabilities and I cannot wait until it's integrated more with Netbeans and the JDK itself. Check out the road map.

http://www.oracle.com/technetwork/java/javafx/overview/roadmap-1446331.html
 
 
subject: Java GUI - what to choose - Swing, JSF, JavaFX, other?