Java 7 for Absolute Beginners

(nextflipdebug5) #1

CHAPTER 7 ■ WRITING A USER INTERFACE


Table 7-1. MineSweeper classes

Class Name Description

MineSweeper The program class. It contains the user interface (Swing) elements and has
links to the game's functionality (which is in the other classes).

MineField (^) Models a minefield. Contains Mine objects.
Mine Models an individual mine.
MineIcon Defines and makes available the mine icons.
MineSweeperActionListener Listens for menu actions.
MineSweeperMouseListener (^) Listens for mouse actions that affect the play area (left clicks and right
clicks).
MineSweeperHelper Convenience class that contains the game's logic.
Let's start with the program class (MineSweeper). After listing 7-4, I'll describe the flow of control
through the class (in other words, the logic of it) and describe each method. Compared to other things
we've done, it's a big and complex class. For now, read through it, even if it doesn't seem to make sense.
Then we'll work through it in detail. Listing 7-4 shows the MineSweeper class. Before we get into the
listing, though, let's see what we're going to get from the MineSweeper class, in Figure 7-4.

Free download pdf