Wednesday September 05, 2007
A simple JavaFX application developed using NetBeans 6.0
Sun introduced JavaFX script at the 2007 JavaOne Conference. Like most engineers it peaked my interest and curiosity to try it out. I put this small sample application together fairly quickly. It is pretty easy to code once you get started. I couldn't find a simple example with both input and output components working together , and String conversion all in one example. So I decided to write this simple Temperature Conversion application in JavaFX. It is already written using NetBeans in the Java Tutorials . Here the Celsius Converter Application uses swing. This also allows to give a comparison on how things are done differently in JavaFX. A similar application is also written in JavaFX using the Spinner and Slider components. I also found the learning curve journals very useful.
To use the application, the user enters a temperature (in Celsius) into the Text field, clicks the "Convert" button. The converted temperature appears in Fahrenheit in the output Fahrenheit label field. The minimize, maximize, and close buttons behave as expected, and the application has a title that appears along the top of the window. This is exactly as per the application written in swing. If the user enters an invalid number (for example text characters etc..), a message appears in the Text field prompting the user to Enter a valid number. Note the String conversion and the exception catching in the code below.
The screen shots followed by the sample code





The JavaFX Source Code for Celsius Converter Application
Following are the references I used for JavaFX:
Posted at 12:05PM Sep 05, 2007 by radhika in NetBeans | Comments[2]
Thank you very much for the insights in this tutorial. Can't wait to get some real project done using JavaFX... :)
Cheers,
Kristian
Posted by kawazu on January 08, 2008 at 05:06 AM PST #
BTW, I'd recommend checking out the current development version of the JavaFX compiler, at
https://openjfx-compiler.dev.java.net/source/browse/openjfx-compiler/
That's because the JavaFX Scripting language is still changing, and regularly updated checkouts of the compiler is the best way to keep up with any changes. See Jim Weavers' blog at:
http://learnjavafx.typepad.com/weblog/2008/01/compiled-javafx.html
for example of some of these language changes.
The JavaFX compiler source is set up as a NetBeans project, so you'll have little difficulty building the javafxc.jar that will allow you to use NetBeans 6 editing features directly with .fx source files in the IDE.
Posted by Brad Mayer on January 09, 2008 at 06:59 AM PST #