8. Controlling Program Flow

This chapter looks at the JavaFX statements that control the flow of execution within a JavaFX script—if, while, for, and throw. As you’ll see, the while statement is almost identical to its Java equivalent, whereas the JavaFX if and for statements are significantly more powerful because they can also be embedded in expressions. The second part of this chapter covers exception handling in JavaFX, which is less intrusive than it is in Java and is likely to be of relevance more to library implementers than to application developers.

The if Statement

The syntax of the JavaFX if statement looks like this:

if (boolean expression) [then] statement [else statement]

In its simplest form, the if statement lets you execute ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.