This article will help you get started with the JavaFX programming language is an introduction to the JavaFX programming language, targeted to those who are already familiar with Java technology and the basics of scripting languages.
The JavaFX Pad Application
If you have a Java Runtime Environment (JRE) on your system, the easiest way to get started with JavaFX technology is to fire up the Java Web Start-enabled demonstration program, JavaFX Pad. Once you start the application, you should see a screen similar to what appears in Figure 1

Figure 1. The JavaFX Pad Application Running on Microsoft Windows OS, JDK 6
JavaFX Pad starts with a default application already loaded, which it immediately executes. The JavaFX Pad application is a great way to see exactly what you're doing at runtime, modifying changes as you go, and instantaneously seeing the results
JavaFX Technology: A Statically Typed Language
The JavaFX programming language is a scripting language with static typing. What exactly does this mean? Consider the following:
var myVariable = "Hello";
This declaration, similar to what you may find in JavaScript technology, creates a variable called myVariable and assigns it the string value Hello. However, after declaring the variable, let's try to assign it something other than a string:
myVariable = 12345;
Because the code does not use quotation marks around 12345, this variable is now being assigned an integer instead of a string. In JavaScript technology, dynamically retyping the variable will work fine. However, a statically typed language such as JavaFX will not allow this. This is because myVariable was initially declared as a String type, and the code later tries to reassign it as an integer. With JavaFX, a variable that is declared as a String must remain a String.
In fact, if you enter those two lines of code into the JavaFX Pad demo, you'll immediately see an error at the bottom of the window, as shown in Figure 2.

No comments:
Post a Comment