public void mouseMoved(MouseEvent e) { if ((e.getX() > PADDLE_WIDTH / 2) && (e.getX() < WIDTH - PADDLE_WIDTH / 2)) { double x = e.getX() - PADDLE_WIDTH / 2; double y = HEIGHT - BRICK_Y_OFFSET - PADDLE_HEIGHT; paddle.setLocation(x, y); } }
/** When mouse moved: move the board */ public void mouseMoved(MouseEvent e) { board.move(e.getX() - board.getX() - BOARD_WIDTH / 2, 0); }