Page 1 of 2 12 LastLast
Results 1 to 20 of 23
Like Tree13Likes

Thread: Swing vs JavaFX?

  1. #1
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Question Swing vs JavaFX?

    I know, this is broad, subjective, and probably something you'd expect from a "which is better: eclipse or netbeans" newbie. But hear me out!

    At my day job, I'm a Swing developer. The company needs a new UI developed, and I'm thinking about using JavaFX instead of Swing, just to try it out. I've heard that JavaFX is the way of the future, so it makes sense to use that instead of Swing for a brand new project.

    But now I'm googling and trying to figure out exactly *how* JavaFX is better than Swing, mostly looking for something to send to management as an explanation of why I want to use it. But the more I read, the less sure I am of my original decision!

    I've been reading a bunch of articles, but they all seem biased. The oracle article just complains that html5 is a fad (and JavaFX isn't, because...?), but this ZeroTurnaround article lists positives of JavaFX that don't really sound that exciting (specifying your GUI as XML). This article says to stick with Swing. Everything else is just opinion.

    Now I'm even less sure than I was when I started out. All I've got is "JavaFX is the way of the future", but no official word from Oracle on that. The only perk I have is "You can style JavaFX with CSS", which isn't that big a perk since it will probably take me longer to get the CSS right than if I was just using Swing.

    I keep hearing that JavaFX is the way of the future... but *why* is it the way of the future? I know JavaFX has become an official part of the JDK, but it's not like they're going to deprecate Swing. I keep seeing stuff like "Oracle is going to stop working on Swing and focus only on JavaFX", but nothing from an official source, just speculation (which doesn't even seem realistic).

    I'm hoping to get some feedback from you guys. It all seems subjective, but as a front-end Java developer, I feel like I should have some more objective information on this than I do. Have you guys seen any other articles that go into more detail about the benefits of JavaFX over Swing (or vice versa)? Do any of you use JavaFX in real life?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Swing vs JavaFX?

    Unfortunately, I can't offer any informed opinion not having worked with JavaFX. But I am getting familiar with Android (and struggling with the simulators). I noticed that Android apps also use XML to layout the GUI. I wonder if that is a coincidence?

    Regards,
    Jim
    KevinWorkman likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Swing vs JavaFX?

    Everything else is just opinion.
    OK, so here's my opinion :-)

    Oracle has declared Swing to be in 'maintenance mode' which means we shouldn't expect any new API. Age-old bugs exist and my not be rectified, ever. By contrast, FX is still evolving, which means new components and features may yet be added (there's no Spinner yet, but there *is* a DatePicker -- something the Swing toolbox will never contain).

    FX uses a superior rendering engine, allowing 3D transforms. Yup, not a selling point for a business application.

    But IMHO the real superiority of FX lies in its use of the Collections API, something retrofitted to only a few Swing classes. And the aforementioned DatePicker uses the new Date/Time API; to use that with Swing you'll have to roll your own renderers and editors (I did, but that's another story...).

    Up to Java 7, some FX code was highly verbose, but with Java 8 lambdas, that's gone now.

    In any case, since your business application evidently has a good separation of model and view, you can create both Swing and FX front ends, then compare the code for readability/maintainability as this will probably drive your choice much more than the official 'advantages' of FX. Good luck!

    db
    KevinWorkman likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Swing vs JavaFX?

    I will say, depending on your company, having the ability to change the structure of the front end by simply fiddling with some CSS is a plus.
    Other than that, it's basically what Darryl says.
    KevinWorkman likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Swing vs JavaFX?

    I will say, depending on your company, having the ability to change the structure of the front end by simply fiddling with some CSS is a plus.
    Other than that, it's basically what Darryl says.
    KevinWorkman likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Swing vs JavaFX?

    So important, it needed to be said twice.
    KevinWorkman likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Swing vs JavaFX?

    Of course.

    I'm beginning to to think I ought to repeat everything I say, as it's invariably important.

    ...
    KevinWorkman likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Swing vs JavaFX?

    You usually do, only not in the same thread ;)
    KevinWorkman likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: Swing vs JavaFX?

    Quote Originally Posted by jim829 View Post
    Unfortunately, I can't offer any informed opinion not having worked with JavaFX. But I am getting familiar with Android (and struggling with the simulators). I noticed that Android apps also use XML to layout the GUI. I wonder if that is a coincidence?
    I've heard that one of the benefits of defining your GUI as XML is that it's much more natural to use a GUI builder- since the GUI builder is creating XML instead of code, its output is a little more sane.

    Maybe I'm just on the wrong side of history, but the idea of using GUI builders is still gross to me.

    Quote Originally Posted by DarrylBurke View Post
    Oracle has declared Swing to be in 'maintenance mode' which means we shouldn't expect any new API.
    I've seen that opinion elsewhere, and it's one of my main motivations. However, I'm having trouble finding an "official" source saying that Swing won't be updated anymore- all my googling just points me to other people saying it, but nothing official from Oracle. Am I missing something obvious?

    Quote Originally Posted by DarrylBurke View Post
    FX uses a superior rendering engine, allowing 3D transforms. Yup, not a selling point for a business application.
    This is interesting, but yeah, not really a use-case for us. In fact, I wonder who this is aimed at, since anybody who cares about 3D is using JOGL or LWJGL anyway. I guess it's good to have stuff that works "out of the box" instead of relying on 3rd party libraries.

    Quote Originally Posted by DarrylBurke View Post
    In any case, since your business application evidently has a good separation of model and view, you can create both Swing and FX front ends, then compare the code for readability/maintainability as this will probably drive your choice much more than the official 'advantages' of FX.
    Yeah, there's definitely a good separation- the model is already built, and I "just" have to build the GUI on top of it. But given the nature of my job (rapid prototyping), I'm not sure I'll have the time to build two separate front ends. That would be nice though.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Swing vs JavaFX?

    Regarding Swing being put to sleep: you don't need an official statement, you only have to see that nothing at all happened with either Java2D or Swing in both Java 7 and Java 8 and nothing is planned for Java 9 and 10.
    Regarding declarative XML: Nothing is stopping you from building your GUI programmatically in JavaFX 2. Having a more declarative method is useful if you have to team up with people who are not programmers, but it is not mandatory.

    I'm curious: for what kind of application stack will this "new gui" be developed? What does it do?
    KevinWorkman likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: Swing vs JavaFX?

    Quote Originally Posted by gimbal2 View Post
    Regarding Swing being put to sleep: you don't need an official statement, you only have to see that nothing at all happened with either Java2D or Swing in both Java 7 and Java 8 and nothing is planned for Java 9 and 10.
    This is a good point. However, there were some Swing additions in Java 7- mostly I'm talking about the JLayer class. But you're right about the future.

    Quote Originally Posted by gimbal2 View Post
    Regarding declarative XML: Nothing is stopping you from building your GUI programmatically in JavaFX 2. Having a more declarative method is useful if you have to team up with people who are not programmers, but it is not mandatory.
    Oh yeah, I know. I wonder which is the more "thinking in JavaFX" approach: using XML or doing it all in code?

    Quote Originally Posted by gimbal2 View Post
    I'm curious: for what kind of application stack will this "new gui" be developed? What does it do?
    Without getting into the boring details, I work for the FAA doing prototype work. (Picture the screens that air traffic controllers look at while telling planes what to do.) This new gui will be added to an existing application suite (mostly done in C and C++) on top of a new Java backend that deals with certain types of airspace decisions.

    As far as the "application stack", this is a set of client-side applications that interact with one another. The "backend" is mostly a non-web data feed, and we have a bunch of different GUIs that interact with that feed. I'm explaining that very poorly, haha, but those are the basics.

    If you're insanely curious, googling "faa nextgen" gives you a little peek into what I do, and googling "CTOP" is specifically this project.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  12. #12
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Swing vs JavaFX?

    You say "GUI", but I'm getting the idea that this GUI is less about boring input dialogs and more about data visualization?
    KevinWorkman likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  13. #13
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Swing vs JavaFX?

    Quote Originally Posted by gimbal2 View Post
    You say "GUI", but I'm getting the idea that this GUI is less about boring input dialogs and more about data visualization?
    I agree. To me a GUI is more like a series of well placed "knobs" for entering input. But I guess the views one gets are interfacing with the eyes and brain and they are or can be graphical in nature so I now have a new perspective.

    Regards,
    Jim
    KevinWorkman likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  14. #14
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: Swing vs JavaFX?

    Quote Originally Posted by gimbal2 View Post
    You say "GUI", but I'm getting the idea that this GUI is less about boring input dialogs and more about data visualization?
    Yeah, exactly.

    There is a little bit of the boring "push this button and fill in this field" stuff, but the most interesting part of my job is when somebody says "we have XYZ data... how do we visualize it?" and I get to come up with some fun, interactive display that shows the data in a form that makes sense for what we're trying to do.

    And then they see it and inevitably say "no, that's horrible, what if we changed this to that", restarting the whole process. But that's what makes it prototyping, haha.

    For example, my previous project had a bunch of data at both the national level and the airport-specific level, so we needed a way to "drill down" into that. My job was to create an interactive map (using GWT and GoogleMaps, which was cool) that displayed different "levels" of that data. Pretty cool. Our product isn't public, but it looks something like this: FlightAware MiseryMap
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  15. #15
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: Swing vs JavaFX?

    Quote Originally Posted by jim829 View Post
    I agree. To me a GUI is more like a series of well placed "knobs" for entering input. But I guess the views one gets are interfacing with the eyes and brain and they are or can be graphical in nature so I now have a new perspective.
    Maybe I'm misusing the term GUI (if so, crap, I should probably stop calling myself a GUI programmer, haha), but to me a GUI can become much more than just a series of boring "fill out this form, press this button" screens. It's anything you can see (graphical), use, or interact (interface) with. And for anything interesting, that's going to be much more than a series of buttons and forms.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  16. #16
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Swing vs JavaFX?

    Just trying to paint a picture and not trying to redefine terminology, what you work on is quite non-standard in this day and age :) If it were of the "boring knobs and buttons" variety then it would have been a more viable option to employ web technologies, but for what you have here specifically either Java or a client .NET application is far more suitable. Given there already is a Java layer in between, Java is then the only option. In my experience of course.

    So yeah - its a tough decision. Do you go for JavaFX and let go of what you are incredibly comfortable with, or do you stick with comfortable Swing and are left a little uncertain about what that might imply for the near future?


    Pros of Swing: rapid development, personal familiarity, available rich documentation and maturity

    Cons of Swing: you don't know how well it will work in the future; operating systems and hardware keep evolving, Swing/Java2D does not; it might also look a little dated, but there are look & feels that fix that.

    Pros of JavaFX: it has a better designed API and is built for modern hardware (but who knows for how long); Oracle still thinks its relevant (but who knows for how long). From what I've learned the design philosophy behind JavaFX 2 meshes better with the application requirements.

    Cons of JavaFX: I guess the maturity, less chance of an answer to a problem/question due to less Java relics... I mean "experts" having experience with it?


    One thing I find very important nowadays is that of independence. I have been stuck in an environment where I had to keep using legacy web technology in the form of Javaserver Faces 1.2 and Richfaces 3.3. That wouldn't be a problem, but those technologies are not further developed and Richfaces 3.3 does not support anything above Internet Explorer 9. Hence the application using it cannot function properly under IE10 or higher with absolutely no way to workaround it - and its company policy to use internet explorer as the default. Quite a shitty situation to be in.

    Hence I'm rather more inclined to not stick with legacy technologies anymore and I try to Move With the Flow Rather Than With What I Know. In that respect, this would be the moment where I just say "f*ck it, JavaFX 2 it is".
    KevinWorkman likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  17. #17
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: Swing vs JavaFX?

    Quote Originally Posted by gimbal2 View Post
    what you work on is quite non-standard in this day and age :)
    Haha, yeah. Sometimes I get a little panicked when I realize that I've worked myself into a career corner and nobody else would ever hire me as a Swing developer, but I think (hope?) this niche is still alive in places. I do a bit of web stuff at home, but you're right, I'm definitely a dying breed. Part of my desire to try out JavaFX in a professional setting is to keep up with newer trends, but that might be a little bit like trying to buy the fastest horse after cars were invented, haha.

    Quote Originally Posted by gimbal2 View Post
    If it were of the "boring knobs and buttons" variety then it would have been a more viable option to employ web technologies, but for what you have here specifically either Java or a client .NET application is far more suitable. Given there already is a Java layer in between, Java is then the only option. In my experience of course.
    It's definitely going to be Java- web stuff simply won't work in this environment. Only question is: stick with Swing or go with JavaFX?

    Quote Originally Posted by gimbal2 View Post
    So yeah - its a tough decision. Do you go for JavaFX and let go of what you are incredibly comfortable with, or do you stick with comfortable Swing and are left a little uncertain about what that might imply for the near future?
    I'm pretty comfortable with a little uncertainty. It just feels a bit like trying to predict the future: in 5 years will JavaFX just have been a fad? I don't see it overtaking Swing anywhere else other than "in theory". On the other hand, in 5 years will all Swing applications seem old, even in settings where "rich applications" are still the norm?

    Quote Originally Posted by gimbal2 View Post
    One thing I find very important nowadays is that of independence. I have been stuck in an environment where I had to keep using legacy web technology in the form of Javaserver Faces 1.2 and Richfaces 3.3. That wouldn't be a problem, but those technologies are not further developed and Richfaces 3.3 does not support anything above Internet Explorer 9. Hence the application using it cannot function properly under IE10 or higher with absolutely no way to workaround it - and its company policy to use internet explorer as the default. Quite a shitty situation to be in.
    Hahaha, I feel your pain. Don't tell anybody, but there are certain projects at my job that are still stuck back on Java 6.

    Quote Originally Posted by gimbal2 View Post
    Hence I'm rather more inclined to not stick with legacy technologies anymore and I try to Move With the Flow Rather Than With What I Know. In that respect, this would be the moment where I just say "f*ck it, JavaFX 2 it is".
    I think that's pretty much where my head's at.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Swing vs JavaFX?

    Quote Originally Posted by KevinWorkman View Post
    Haha, yeah. Sometimes I get a little panicked when I realize that I've worked myself into a career corner and nobody else would ever hire me as a Swing developer, but I think (hope?) this niche is still alive in places. I do a bit of web stuff at home, but you're right, I'm definitely a dying breed. Part of my desire to try out JavaFX in a professional setting is to keep up with newer trends, but that might be a little bit like trying to buy the fastest horse after cars were invented, haha.

    It's definitely going to be Java- web stuff simply won't work in this environment. Only question is: stick with Swing or go with JavaFX?
    You have a niche.
    And as time goes on there'll be fewer people willing or able to fill that niche (unless app dev paradigms shift in the next few years).
    Me? I always go for the "pad the CV" option.
    You have the choice...if it were me, since Swing is already most definitely "in the bag", I'd go for FX.

    As for XML or hand craft, I've only hand-crafted FX stuff, simply to see how the nuts and bolts fit together. However having dabbled in Android I can see the appeal of XML definitions.
    KevinWorkman likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  19. #19
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: Swing vs JavaFX?

    Quote Originally Posted by Tolls View Post
    You have a niche.
    And as time goes on there'll be fewer people willing or able to fill that niche (unless app dev paradigms shift in the next few years).
    That makes me feel a lot better! And hopefully my hobby stuff turns me into a famous millionaire and I don't have to worry about any of that, hahaha.

    Quote Originally Posted by Tolls View Post
    Me? I always go for the "pad the CV" option.
    You have the choice...if it were me, since Swing is already most definitely "in the bag", I'd go for FX.
    Yeah, that's what I'm thinking.

    Quote Originally Posted by Tolls View Post
    As for XML or hand craft, I've only hand-crafted FX stuff, simply to see how the nuts and bolts fit together. However having dabbled in Android I can see the appeal of XML definitions.
    Yeah, I guess I'm in the same boat. It seems a little gross to me, but I do see the appeal.

    Anyway, thanks a lot guys- I'll be going with JavaFX!
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  20. #20
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Swing vs JavaFX?

    You can "ha ha" the doubts away but I have the same doubts and worries; I (too?) had the idea I was making myself irrelevant fast by staying in circles where I don't get the chance to grow with the market demands with "on the job training". Fulfilling a demand that less and less people compete for is in some ways great, but it hurts in the butt come the time where you want to do something else yourself or the demand for such skills drops below a point where you have don't even have a choice of workplace anymore and need to grab what you can get. If you don't do anything about it, its only too easy to see yourself ending up right in that unfortunate position.

    Its not a great feeling that sticks with you every day and it eventually starts to affect your overall mood and even health if left unchecked; I hope going down the JavaFX path does not make that gloomy feeling any worse for you. I managed to brighten my mood by in fact thinking about possible alternative ventures for that "future after Java" as I call it. When the list starts growing, it becomes increasingly more fun to think up more alternatives. In my case many items on the list even imply a "future after IT". Next to making that list I actually do study up on modern demands of the software engineer as many here seem to do; I picked full-stack Javascript programming myself (you know, "html 5") whereas others have gone for mobile development in the form of Android.

    The latter might be of great interest to your particular working environment.
    KevinWorkman likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Page 1 of 2 12 LastLast

Similar Threads

  1. JavaFX vs. Swing
    By MW130 in forum New To Java
    Replies: 15
    Last Post: 03-05-2016, 06:45 PM
  2. Diving into JavaFX from Swing
    By rru96 in forum JavaFX
    Replies: 1
    Last Post: 04-17-2014, 09:31 AM
  3. JavaFX Book | Learn JavaFX More In Depth
    By SnakeDoc in forum JavaFX
    Replies: 0
    Last Post: 05-17-2013, 11:10 PM
  4. JavaFX 2.0 and/or Swing
    By JavaPete in forum Forum Lobby
    Replies: 2
    Last Post: 10-25-2012, 09:36 AM
  5. JavaFX Script and JavaFX Mobile
    By levent in forum Java Software
    Replies: 1
    Last Post: 01-27-2010, 04:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •