This discussion is archived
2 Replies Latest reply: Oct 1, 2013 12:10 PM by Thomas_Berglund RSS

Does the lack of Open GL support in Java FX 2 force us to use Swing?

Thomas_Berglund Newbie
Currently Being Moderated

Hi,

 

 

 

We are about to start the development of a major User Interface in Java. Naturally, we would prefer to implement this in Java FX 2, rather than Swing. However, we need to render heavy 3D models (generated from several CAD files) with overlay from 3D point clouds with ~400K points. We already have a Swing implementation that supports this, based on the JOGL API. What I have understood, there are no support for JOGL or similar OpenGL wrapper in Java FX 2. Instead, Java FX 2 seems to aim at a high level 3D API. Based on previous attempts to use similar high level API's in the .NET world (e.g. WPF 3D), high level 3D API's are usually not appropriate when working with large and complex 3D models.

 

 

 

Therefore, I would like to ask for suggestions on what to do here. Do we have to develop our new User Interface in Swing because of this? Or can the announced JavaFX SwingNode be used to wrap such a complex Swing component? If so, how would the performance suffer from the JavaFX wrapping? If the SwingNode doesn't solve the issue and we therefore need to implement the main application in Swing, should we still consider implementing non-3D sub-views with Java FX 2 or should we go for Swing all the way? Our developer group has previous experience from Swing, but none from Java FX. Still, it does not feel right to start the development of a new UI - which we intend to maintain for many years from now - using a deprecated application framework. We are about to decide our way forward here and would really appreciate any thoughts on this topic.

 

 

 

Thanks,

Thomas Berglund

  • 1. Re: Does the lack of Open GL support in Java FX 2 force us to use Swing?
    jsmith Guru
    Currently Being Moderated

    See this StackOverflow question: How to use OpenGL in JavaFX?

     

    It sounds like the best answer for you is the addition of an OpenGL node to JavaFX.

    An OpenGL node has not yet been added to the JavaFX platform.

    As you have a team of people experienced in 3D development and Java and all of the relevant JavaFX code is open source, I'd encourage you to consider creating an OpenGL node or working with Oracle to create one and (if you are inclined) contributing the development back to the JavaFX code base.  If you are interested in this, contact the openjfx-dev mailing list.

     

    > Do we have to develop our new User Interface in Swing because of this?

     

    I don't think so.

     

    > Or can the announced JavaFX SwingNode be used to wrap such a complex Swing component?

     

    I don't know, but it doesn't sound quite the right approach to me.

    It seems a dedicated OpenGL rendering node would be a better fit as long as you don't need other Swing functions in your SwingNode.

     

    > If so, how would the performance suffer from the JavaFX wrapping?

     

    I think if you had a JavaFX Node which was a Swing Node which handled OpenGL then performance would likely be worse than a JavaFX Node that handled OpenGL directly.

     

    > If the SwingNode doesn't solve the issue and we therefore need to implement the main application in Swing, should we still consider implementing non-3D sub-views with Java FX 2 or should we go for Swing all the way?

     

    Either way would work, but I do not recommend mixing the technologies for your application unless you need to.

     

    There are some considerations with mixing JavaFX and Swing:

    1. Swing widgets look different from JavaFX widgets (and it's not trivial to make them look the same).

    2. You have to learn two toolkits then mentally switch between them when developing (this is just annoying).

    3. You have to be (very) careful of threading issues as each toolkit has it's own primary thread.

    4. There are some bugs in mixing JavaFX and Swing (search JFXPanel in the issue tracker) that simply wouldn't occur if you weren't mixing libraries (most of these bugs have been addressed but some are outstanding).

    5. The Swing functionality isn't going evolve, it's good at what it does, but it is not going to change and get better.

    There is (very experimental) work in merging the JavaFX and Swing application threads, which makes a combined programming model a bit nicer to deal with, but it remains to be seen if that experimental feature becomes a default for both platforms.

     

    Unless you want to reuse existing extensive Swing libraries (like NetBeans RCP), a pure JavaFX application seems preferred (as long as the OpenGL node can be worked out).

     

    > Our developer group has previous experience from Swing, but none from Java FX.

     

    There are similarities, previous knowledge of Swing is a benefit, but there are a lot new things to learn in JavaFX (and a few things to unlearn from Swing likely).

     

    My 2c . . . best of luck with your project.

  • 2. Re: Does the lack of Open GL support in Java FX 2 force us to use Swing?
    Thomas_Berglund Newbie
    Currently Being Moderated

    Thank you very much for your extensive reply jsmith! All you say makes sense.


    A dedicated OpenGL rendering node would most likely be the best solution for us, but I am afraid we will have to settle with Swing for now. Our project is already behind schedule and we won't be able to get resources for framework development at this time, even though it sounds both interesting and fun. I will forward the suggestion to our companies central department though, who supports us with framework and strongly suggests us to use Java FX 2 instead of Swing.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points