1. 12
  1.  

  2. 5

    What is JavaFX? Every time I’m trying to figure out what is it, I find only lots of nonsensical marketing terms like “Rich Internet Applications”, “Rich Client Platform”, as well as ancient dotcom-crash-era buzzwords like “multimedia”. Looks like it’s GUI toolkit that had been planned to replace Swing, but it completely lacks native look and everything is based on skins (hello from 2001). Is it usable toolkit, or just enterprise gimmick to display interactive sales charts?

    1. 10

      I used it on a large-ish desktop project. It’s quite a nice library. It’s easy to use in common cases, has a very clean and regular UI, and is really, really fast. We use the CSS styling just a bit (to offer a dark theme) but not much of the XML-based scripting stuff.

      It’s much easier to use than Swing, thanks in part to backing away from the L&F split.

      Oh, JavaFX also makes it dead easy to get an OpenGL context in a panel.

      1. 2

        So, it’s more similar to Qt Quick and Clutter than Silverlight or Adobe Air?

        And is “traditional” GUI with input boxes, lots of buttons, resizable layouts doable in it? Can I just instantiate trees of these elements without dealing with skinning details or OpenGL? Do standard interactions (selecting text in text boxes with mouse or keys, clipboard, cursor movement, scrolling) work as expected, unlike, for example, some GUIs in game engines?

        1. 8

          I don’t know Qt Quick and Clutter, so I can’t comment. Definitely in the first release, JavaFX was positioned as a competitor to Silverlight and Air. JavaFX 1 was all about the XML to make it declarative and script-driven. With JavaFX 2 they seemed to back away from that positioning a bit.

          As far as the expected complement of widgets, yep. They’re all there. You don’t have to deal with CSS or skinning if you don’t want to. Just instantiate the components and go. All the interactions you’d expect are there. It’s not like an OpenGL rebuild of a GUI toolkit. It’s a GUI toolkit that also makes it easy to show OpenGL.

          (The docs can be a little misleading here again, because they talk about a “stage” and a “scene”, which makes it sound like a 3d engine. It’s not.)

          Another thing I liked is that they extended the JavaBeans getter/setter model with active property objects. Instead of creating a custom listener interface for everything like in AWT, you can just bind to specific properties and get notified about changes to those. That gives you a narrower interface that’s used more broadly… which makes it super-easy to use from Clojure. :-)

          One thing I dislike is that you’re expected to have your main class be a subclass of javafx.application.Application. They want to take control of initial class loading and application startup. There’s a goofy workaround needed if you want (like me) to have main be a Clojure function. That’s not of general interest though so I won’t clutter this post up with it.

      2. 4

        JavaFX was, if I recall properly, the first widespread attempt at doing reactive programming in the UI. I think it grew from the community (Romain Guy was the main developer), as it is too innovative to be something that was created out of a top-down approach. I was happily surprised when it got integrated into the JDK, for obvious strategic reasons at the time, as mentioned in other comments.

        1. 2

          Oracle’s marketing is strange. I got interest to try it only after comments here, official webpages for JavaFX only repelled me. It looked like top-down thing to resurrect applets, I didn’t even know it’s a GUI toolkit and not chart plotting or animation lib.

        2. 3

          It has confusingly referred to several different things over the past, but in this context, it’s really just a UI toolkit - it could be seen as a replacement for Swing.

          I find that it’s nicer to use in some ways than Swing (I don’t particularly like the concept of CSS for regular UIs, but it does make altering style and positioning quick and easy), but it’s less complete, lacking features (such as an extensible text editor kit) that the more mature Swing does have. It’s also more buggy and sometimes slower than Swing, and has some ill-conceived design choices (weak references in property bindings, urgh).

          1. 0

            It’s basically like the interface builder in xcode but just for Java.

            1. 3

              Examples for beginners “Getting started with JavaFX” does not use any builder: first widgets are instantiated directly and then defined in xml. Interface builder probably exists too but it’s definitely not a killer feature of JavaFX, and UI builders exist for Swing too.

              1. 1

                Thanks for the correction! So it’s more like the XML layouts for Android?

                1. 2

                  According to other comments here and some introductional docs, it’s just another GUI toolkit for Java, alternative to Swing, but more “modern” and without native look-and-feels. XML is just one of features. It was initially marketed as alternative to Silverlight, but in reality it’s another GUI toolkit.

          2. 4

            I had to write a couple of very small desktop apps using it.

            Simple things like “I want this widget to fill all unused space in its parent” or “I want the parent to automatically calculate its dimensions using the preferred dimensions of its children, while simultaneously expanding as large as possible in its parent” are decidedly not intuitively done. “I want this text box’s dimensions specified in terms of characters it can hold or percentage of its parent’s size, etc…”

            Even things like “I want multiple windows” doesn’t really have an obvious (to me, at least) solution. I got all of these things working, but I have no idea if I did it in an idiomatic way or not, because it was so weirdly put together.