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]