O'Reilly logo

JavaFX™ Developer’s Guide by Kim Topley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required