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

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

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