Revampled MainFrame layout to improve appearance/usability when the number of tiles is very large or small.

Fixed instantiation where a new MouseListener was used to each tile - now only one is used for all Tiles.
Fixed issue where the MouseListener was being added to each tile twice.
This commit is contained in:
Woody Folsom
2012-04-14 12:02:17 -04:00
parent 9619f9a96d
commit 74b8eb4622
7 changed files with 154 additions and 222 deletions

View File

@@ -35,17 +35,15 @@ public class BoardPanel extends JPanel {
referee = ref;
setLayout(new GridLayout(Board.NUM_ROWS, Board.NUM_COLS));
BoardPanelMouseListener bpml = new BoardPanelMouseListener(this, tsp, referee.getHumanPlayer());
BoardPanelMouseListener bpml = new BoardPanelMouseListener(tsp,
referee.getHumanPlayer());
ImageIcon noneIcon = new ImageIcon(NONE_ICON);
for (int r = 0; r < Board.NUM_ROWS; r++) {
for (int c = 0; c < Board.NUM_COLS; c++) {
Tile tile = new Tile(noneIcon,r,c);
Tile tile = new Tile(noneIcon, r, c);
board[r][c] = tile;
tile.addMouseListener(bpml);
board[r][c].addMouseListener(bpml);
board[r][c].addMouseWheelListener(bpml);
add(board[r][c]);
}
}