📜 ⬆️ ⬇️

JavaFX - "plasticine crow"

As Java programmers (and not only) already know, the official release of JavaFX recently took place. I periodically showed interest in this direction. It's time to specifically feel what kind of "beast" is this with fashionable letters FX. Programming horrible (that is, training on cats) is certainly not interesting. Accordingly, with advantage for the case, I wrote a component for the web file upload service. Uploader under the Hivext platform.

First impressions of JavaFX of course muddled. The product was pretty interesting. The programming syntax is formed from a mixture of Java and JavaScript languages. After writing my first full-fledged application, I got the impression of "plasticine language." In my opinion a very flexible syntax was obtained. Remember what transformations were in the cartoon "plasticine crow"? With JavaFX, you can do something like this.

A couple of interesting examples


When defining properties of an object, you can separate them with a comma and you can also with a space, but you can not divide them at all! (experimentally calculated)
')
translateY: 5,
width: 330

translateY: 5 width: 330

translateY: 5width: 330

all three code examples work identically.

Swing component conversion

The following example intrigued me greatly. 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, this way you can use any standard component (this is my unverified assumption).

Creating a file selection dialog

Easier steamed turnip
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 the Java libraries, we received a new additional syntax and functionality.

A working example of a JavaFX-based SimpleUploader file loader with source code.

It’s still hard to predict how the future fate of JavaFX will evolve. I know one thing - another handy “jigsaw” appeared in my toolkit, which I hope will not get dusty.

Source: https://habr.com/ru/post/47106/


All Articles