This chapter begins our discussion of the JavaFX Script programming language by looking at the structure of a JavaFX source file. All JavaFX code is placed in source files, which, by convention, use the naming suffix
.fx and are converted by the JavaFX compiler into a set of equivalent class files for execution on the Java Virtual Machine. In this chapter, you see how to structure a JavaFX source file, how to import and use code in existing Java and JavaFX classes, and how a JavaFX script is executed.
A JavaFX source file is structured like this:
• Optional JavaFX statements
Here is a simple JavaFX application that prints a random number: ...