Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1.     private void initField() {
  2.         Color color = Color.green;
  3.         for (int y = 0; y < height; y++) {
  4.             for (int x = 0; x < width; x++) {
  5.                 fields[y][x] = new JLabel();
  6.                 fields[y][x].setOpaque(true);
  7.                 fields[y][x].setBackground(color);
  8.                 fields[y][x].setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
  9.                 fields[y][x].setText(y + ":" + x);
  10.                 //fields[y][x].setForeground(fields[y][x].getBackground());
  11.                 fields[y][x].addMouseListener(new MouseListener(gameWindow));
  12.                 add(fields[y][x]);
  13.  
  14.                 if (x + y % 2 == 0 && y % 2 == 0) {
  15.                     color = Color.pink;
  16.                 } else if (((x + y) % 2 == 0) && (y % 2 != 0)) {
  17.                     //color = Color.black;
  18.                 }
  19.             }
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement