4.3 Graphics Supplement

Painting is silent poetry, and poetry is painting that speaks.

—PLUTARCH (ca. 46–127)

In this section we create a JavaFx application that uses a loop to produce its drawing. The program will also use an if statement and the method setFill, both of which are described in the previous chapter. In addition, we introduce the methods setFont and fillText and use them to write text in the window.

Programming Example A Multiface JavaFx Application

Listing 4.9 contains a JavaFx application that displays a sequence of seven faces. The first five faces alternate in color between light gray and white, and each has a bit more of a smile than the one before. The sixth face is throwing a kiss to the user, and the seventh face is blushing ...

Get Java: An Introduction to Problem Solving and Programming, 8th Edition 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.