Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void initField() {
- Color color = Color.green;
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- fields[y][x] = new JLabel();
- fields[y][x].setOpaque(true);
- fields[y][x].setBackground(color);
- fields[y][x].setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
- fields[y][x].setText(y + ":" + x);
- //fields[y][x].setForeground(fields[y][x].getBackground());
- fields[y][x].addMouseListener(new MouseListener(gameWindow));
- add(fields[y][x]);
- if (x + y % 2 == 0 && y % 2 == 0) {
- color = Color.pink;
- } else if (((x + y) % 2 == 0) && (y % 2 != 0)) {
- //color = Color.black;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement