Java Reference
In-Depth Information
(a)
(b)
(c)
F IGURE 14.44
(a) Five texts are displayed with a random color and a specified font. (b) A string is displayed around the
circle. (c) A checkerboard is displayed using rectangles.
14.5 ( Characters around circle ) Write a program that displays a string Welcome to
Java around the circle, as shown in Figure 14.44b. Hint: You need to display each
character in the right location with appropriate rotation using a loop.
*14.6 ( Game: display a checkerboard ) Write a program that displays a checkerboard
in which each white and black cell is a Rectangle with a fill color black or
white, as shown in Figure 14.44c.
Sections 14.10-14.11
*14.7
( Display random 0 or 1 ) Write a program that displays a 10-by-10 square matrix,
as shown in Figure 14.45a. Each element in the matrix is 0 or 1 , randomly gener-
ated. Display each number centered in a text field. Use TextField 's setText
method to set value 0 or 1 as a string.
Display a random matrix
(a)
(b)
(c)
F IGURE 14.45
(a) The program randomly generates 0s and 1s. (b) Exercise 14.9 draws four
fans. (c) Exercise 14.10 draws a cylinder.
14.8
( Display 54 cards ) Expand Exercise 14.3 to display all 54 cards (including two
jokers), nine per row. The image files are jokers and are named 53.jpg and 54.jpg.
*14.9
( Create four fans ) Write a program that places four fans in a GridPane with two
rows and two columns, as shown in Figure 14.45b.
*14.10
( Display a cylinder ) Write a program that draws a cylinder, as shown in
Figure 14.45b. You can use the following method to set the dashed stroke for an arc:
arc.getStrokeDashArray().addAll( 6.0 , 21.0 );
 
Search WWH ::




Custom Search