Example #1
0
  @Override
  public void mouseClicked(MouseEvent e) {

    // System.out.println("hit: button"+e.getButton()+" pos:"+e.getPoint());
    if (e.getButton() > 1) return;
    int x = pixelToPosition(e.getX(), 0);
    int y = pixelToPosition(e.getY(), 1);

    if (x >= width || y >= height || x < 0 || y < 0) return;

    synchronized (field.lock) {
      if (e.isShiftDown()) {
        field.aliveCells[x][y] = false;
      } else {
        field.aliveCells[x][y] = true;
      }
    }
    e.consume();

    f.invalidate();
    f.repaint();
  }
Example #2
0
 @Override
 public void drawField(GameField field) {
   this.field = field;
   f.invalidate();
   f.repaint();
 }