Java 7 for Absolute Beginners
CHAPTER 7 ■ WRITING A USER INTERFACE frame.getContentPane().add(controlPanel); frame.getContentPane().add(minePanel); } You migh ...
CHAPTER 7 ■ WRITING A USER INTERFACE newItem.addActionListener(actionListener); file.add(newItem); ButtonGroup sizeOptions = new ...
CHAPTER 7 ■ WRITING A USER INTERFACE Now that we're through all the methods, we should look at the fields in the MineSweeper cla ...
CHAPTER 7 ■ WRITING A USER INTERFACE Minesweeper apps already exist for Android—most of my projects are for fun and my own learn ...
CHAPTER 7 ■ WRITING A USER INTERFACE Mine.flagState.MINE) { return gameState.CONTINUE; } if (thisMine.isCleared()) return gameSt ...
CHAPTER 7 ■ WRITING A USER INTERFACE int getMinesFound() { return minesFound; } int getMinesRemaining() { return minesRemaining; ...
CHAPTER 7 ■ WRITING A USER INTERFACE return count; } boolean getMineCleared(int x, int y) { return mineField[x][y].isCleared(); ...
CHAPTER 7 ■ WRITING A USER INTERFACE Listing 7-14. The MineField construcor MineField(int rows, int columns, int mines) { this.r ...
CHAPTER 7 ■ WRITING A USER INTERFACE currentCount++; if (currentCount == mines) { return; } } } } } if (currentCount < mines) ...
CHAPTER 7 ■ WRITING A USER INTERFACE Listing 7-17. The MineField cascade method private gameState cascade(int x, int y) { if (x ...
CHAPTER 7 ■ WRITING A USER INTERFACE Finally, you probably notice that the cascade method returns one of the values from the gam ...
CHAPTER 7 ■ WRITING A USER INTERFACE void setMine() { hasMine = true; } boolean isCleared() { return isCleared; } void clear() { ...
CHAPTER 7 ■ WRITING A USER INTERFACE import javax.swing.JButton; import javax.swing.JOptionPane; public class MineSweeperHelper ...
CHAPTER 7 ■ WRITING A USER INTERFACE if (count > 0) { thisButton.setIcon(MineIcon.getNumberIcon(count)); } } } } } void endGa ...
CHAPTER 7 ■ WRITING A USER INTERFACE MineSweeper class passes itself (with the this keyword) to this class (and to the other uti ...
CHAPTER 7 ■ WRITING A USER INTERFACE the location. If the mine has not been cleared, we enter the outer else block. I say, “oute ...
CHAPTER 7 ■ WRITING A USER INTERFACE Listing 7-25. The MineSweeperHelper endGame method void endGame(boolean won) { showAll(); S ...
CHAPTER 7 ■ WRITING A USER INTERFACE because a method with that problem is overly complex, it's exactly the kind of place where ...
CHAPTER 7 ■ WRITING A USER INTERFACE if (mineCount == 3) return threeIcon; if (mineCount == 4) return fourIcon; if (mineCount == ...
CHAPTER 7 ■ WRITING A USER INTERFACE @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(Mous ...
«
3
4
5
6
7
8
9
10
11
12
»
Free download pdf