JavaFX - "plasticine crow"

    As Java programmers (and not only) already know, the official release of JavaFX was held the other day. I periodically showed interest in this area. It's time to specifically feel what kind of "beast" is this with the fashionable letters FX. Programming horrible (i.e. training on cats) is certainly not interesting. Accordingly, for the benefit of business, I wrote a component for the Uploader file download web service for the Hivext platform.

    The first impressions of JavaFX are of course chaotic. The product is quite interesting. The programming syntax is formed from a mixture of Java and JavaScript. After writing my first full-fledged application, I got the impression of a “plasticine language”. In my opinion, it turned out to be a very flexible syntax. Remember what were the transformations in the cartoon "plasticine crow"? JavaFX can do something similar.

    A couple of interesting examples


    When defining the properties of an object, you can separate them with a comma or you can use a space, or you can not separate them at all! (experimentally calculated)

    translateY: 5,
    width: 330

    translateY: 5 width: 330

    translateY: 5width: 330

    all three code examples work identically.

    Convert Swing Components

    The following example intrigued me very much. Convert standard javax.swing.JProgressBar to javafx component

      var progressBar = new JProgressBar (0, 100);
      progressBar.setStringPainted (true);
      var comp = SwingComponent.wrap (progressBar);

    all !, now comp is a javafx component. In fact, in this way you can use any standard component (this is my unverified assumption).

    Creating a file selection dialog

    Simpler than steamed turnips
    var chooser = new JFileChooser
    // or var chooser = new JFileChooser ()
    // or var chooser = JFileChooser {}
    chooser.showOpenDialog (null);


    My new jigsaw

    In general, my first impressions are very positive. With the current power and richness of Java libraries, we got new additional syntax and functionality.

    A working example of a JavaFX-based SimpleUploader file downloader along with the source.

    It will be difficult to predict how the future of JavaFX will develop. I know one thing - another convenient “jigsaw” has appeared in my tool kit, which I hope will not get dusty.

    Also popular now: