Java Reference
In-Depth Information
10.
A FlowPane arranges the nodes in the pane horizontally from left to right or vertically
from top to bottom in the order in which they were added. A GridPane arranges nodes
in a grid (matrix) formation. The nodes are placed in the specified column and row indi-
ces. A BorderPane can place nodes in five regions: top, bottom, left, right, and center.
An HBox lays out its children in a single horizontal row. A VBox lays out its children in
a single vertical column.
11.
JavaFX provides many shape classes for drawing texts, lines, circles, rectangles, ellip-
ses, arcs, polygons, and polylines.
Q UIZ
Answer the quiz for this chapter online at www.cs.armstrong.edu/liang/intro10e/quiz.html .
P ROGRAMMING E XERCISES
Note
The image files used in the exercises can be obtained from www.cs.armstrong.edu/
liang/intro10e/book.zip under the image folder.
download image files
Sections 14.2-14.9
14.1
( Display images ) Write a program that displays four images in a grid pane, as
shown in Figure 14.43a.
(a)
(b)
(c)
F IGURE 14.43
(a) Exercise 14.1 displays four images. (b) Exercise 14.2 displays a tic-tac-toe board with images.
(c) Three cards are randomly selected.
*14.2
( Tic-tac-toe board ) Write a program that displays a tic-tac-toe board, as shown
in Figure 14.43b. A cell may be X, O, or empty. What to display at each cell is
randomly decided. The X and O are images in the files x.gif and o.gif .
VideoNote
Display a tictactoe board
*14.3
( Display three cards ) Write a program that displays three cards randomly
selected from a deck of 52, as shown in Figure  14.43c. The card image files
are named 1.png , 2.png , …, 52.png and stored in the image/card directory.
All three cards are distinct and selected randomly. Hint: You can select random
cards by storing the numbers 1-52 to an array list, perform a random shuffle
introduced in Section 11.12, and use the first three numbers in the array list as
the file names for the image.
14.4
( Color and font ) Write a program that displays five texts vertically, as shown in
Figure 14.44a. Set a random color and opacity for each text and set the font of
each text to Times Roman, bold, italic, and 22 pixels.
 
 
Search WWH ::




Custom Search