Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Andy Jack
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
K. Tsang
Bartender
Posts: 3348
12
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Steve Myers
Ranch Hand
Posts: 47
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,

Thanks a bunch for the proof. So I need to change now.
 
Campbell Ritchie
Sheriff
Posts: 48448
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this thread would fit better in the GUIs forum. Moving.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 356
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic