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:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user