Appendix B. JavaFX Script: a quick reference

 

This appendix is an ultraterse guide to JavaFX Script, almost like flash cards for each of the topics covered in the main language tutorial chapters earlier in this book. As well as acting as a quick reference to the language syntax, it could also be used by highly confident developers (impatient to get on to the projects) as a fast track to learning the basics of the JavaFX Script language.

B.1. Comments

JavaFX Script supports comments in the same way as Java:

// A single line comment.
/* A multi line comment. */

B.2. Variables and data types—the basics

JavaFX Script variables are statically, not dynamically, typed. The language has no concept of primitives in the way Java does; everything is an object. Some types may be declared using a literal syntax. We call these the value types, and they are Boolean, Byte, Character, Double, Duration, Float, Integer, Long, Number, Short, and String. KeyFrame, an animation class, also has its own specific literal syntax (dealt with in the chapters dealing with animation timelines).

Aside from having their own literal syntax, value types can never be null, meaning unassigned value types have default values. Value types are also immutable.

Variable declaration (def, var, Boolean, Integer, Number, String)

Value types are created using the var or the def keyword, followed by the variable’s name and optionally a colon and a type.

B.3. Strings

B.4. Durations

B.5. Sequences: lists of objects

B.6. Binds

B.7. Cooperating with Java

B.8. Packages (package, import)

B.9. Developing classes

B.10 Conditions

B.11 Loops

B.12 Triggers

B.13 Exceptions (try, catch, any, finally)

B.14 Keywords

B.15 Operator precedence

B.16 Pseudo variables