checkerboard
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
checkerboard [2024/10/29 13:12] – frchris | checkerboard [2024/10/29 13:15] (current) – frchris | ||
---|---|---|---|
Line 2: | Line 2: | ||
Make a checkerboard | Make a checkerboard | ||
+ | |||
+ | |||
+ | Write a graphical application that displays a checkerboard with 64 squares, alternating white and black. | ||
+ | |||
+ | Use nested loops. | ||
+ | |||
<code java CheckerBoard.java> | <code java CheckerBoard.java> | ||
Line 60: | Line 66: | ||
</ | </ | ||
+ | |||
+ | <code java CheckerBoardViewer.java> | ||
+ | import javax.swing.JFrame; | ||
+ | |||
+ | /** | ||
+ | This program displays a checkerboard. | ||
+ | */ | ||
+ | public class CheckerBoardViewer | ||
+ | { | ||
+ | | ||
+ | { | ||
+ | JFrame frame = new JFrame(); | ||
+ | |||
+ | final int FRAME_WIDTH = 330; | ||
+ | final int FRAME_HEIGHT = 360; | ||
+ | |||
+ | frame.setSize(FRAME_WIDTH, | ||
+ | frame.setTitle(" | ||
+ | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
+ | |||
+ | CheckerBoardComponent component = new CheckerBoardComponent(); | ||
+ | frame.add(component); | ||
+ | |||
+ | frame.setVisible(true); | ||
+ | } | ||
+ | } | ||
+ | </ |
checkerboard.1730221940.txt.gz · Last modified: 2024/10/29 13:12 by frchris