JavaFX Script, puh! What a hype you might think, as I thought some weeks ago. I have some tears in my eyes while reading that Sun is not really improving good old Swing. Instead they push a lot of energy and money into JavaFX.
Are this bad news?
I will put here some facts, my notes, my thoughts and some links to give you a basis for your next JavaFX program.
Some Facts
- JavaFX 1.0 is still not released. It should be released on 2nd December (integrated in NetBeans 6.5). (I am a bit confused about the versioning terms but the current version should be 1.0 pre1)
- You will be happy with the current version of JavaFX only if you use NetBeans 6.1 (!), Java 1.6 and Windows or Max OS for development. But this means: your clients will need a jvm like they do for Swing!
- The current version of JavaFX is under GPL
- JavaFX is not Java but you can mix it with Java. See the language introduction. JavaFX is a declarative programming language. E.g. the initialization is in the style of json (->yaml).
- Be sure you read the migration guide before googling for examples! And use the shipped examples in the current version as starting point. (They switched from interpreter version to OpenJFX compiler)
- Project Nile tries to exports a layered graphic from Adobe Illustrator (into JavaFX code). The projects offers libraries to import the exported files as well. It also provides a SVG converter.
The first intention of JavaFX is to improve Swing (not only in my opinion, see from page 22). But Swing could be improved only in two ways
- improve the library and merge awt, swing, java2d and more (1,2) into one consistent library WITHOUT breaking backward compatibility
- and enhance the language to provide such nice features like property binding (via bind)
Nice features in the programming language JavaFX or the API
- ruby style durations: Duration t = 2m + 20s;
- C# style operations: insert, delete … and this is nice:
for (element in group where element.length() < 4) {
println({element});
} - // localization
var localizer = StringLocalizer{ key: “Hello, World!” };
// This prints localized text for “Hello, World!” for the default locale
System.out.println(localizer.localizedString); - javafx can still be used as interpreted language: FXEvaluator().eval(String)
- … a lot more!
Some drawbacks of JavaFX (only the current version?):
- GPL
- no tables or tableNodes!? use this. Where is the Table and TableColumn gone?
- println(String); does not work although documented in the api. You will need to use System.out.println(String) + import java.lang.System.
- The Photoshop exporter is not properly working for me. The .fx file does compile and even after I changed some lines the created UI looks damaged.
Conclusion
JavaFX is a great language which offers some nice features. But the current version is far from perfect and you should wait until the final release in December. But then: try it out! Hopefully they will made a linux version for me 😉
Ressources
- Download JavaFX bundled with NetBeans 6.1
- In NetBeans (with the JavaFX plugin) go to help->javadoc references->JavaFX Script Documentation
- https://openjfx.dev.java.net/JavaFX_Programming_Language.html
- http://java.sun.com/features/#javafx
- https://openjfx.dev.java.net/
- http://javafx.netbeans.org/
- http://learnjavafx.typepad.com/weblog/2008/08/tablenode-creat.html
- http://jfx.wikia.com/wiki/Code_Examples
- http://jfx.wikia.com/wiki/Demos
- QA: http://java.sun.com/developer/community/askxprt/sessions/2008/jl0818.jsp
- http://java.sun.com/javafx/tutorials/project_nile_integrating_graphics/
- clock example: http://java.sun.com/javafx/tutorials/simple_javafx_nb_app/
- svg to fx: http://www.javaworld.com/javaworld/jw-11-2008/jw-11-jump-into-jfx-1.html?page=5
- a lot of (outdated!) examples: https://openjfx.dev.java.net/learning.html
- http://learnjavafx.typepad.com/
- http://widgetfx.org/