练习内容
- 鼠标控制小球抄写3遍,默写1遍
感想
- Panel类中的repaint()方法是用来回调paint()方法的
- MouseListener()与静止动作有关
- MouseMotionListener()与移动动作有关
代码示例
public void paint(Graphics g) {
g.fillOval(x,y,20,20);
}
public void mouseMoved(MouseEvent arg0) {
x = arg0.getX();
y = arg0.getY();
repaint();
}
网友评论