2. JavaFX Script Basics

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.

Source File Structure

A JavaFX source file is structured like this:

• Optional package statement

• Optional import statements

• Optional JavaFX statements

Here is a simple JavaFX application that prints a random number: ...

Get JavaFX™ Developer’s Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.