想实现按住鼠标,然后圆不停的增大.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
class cav extends Canvas 
{
int x=5;
public void cav()

{ getSize();
}
public void paint(Graphics g)
  { x=x+3;
  g.drawOval(10,10,x,x);
  }

public Dimension getPreferredSize()
{return new Dimension(300,300);}
}public class huahua1 extends Frame implements MouseListener
{  TextField text;
 
 Panel p1;
 cav huabu;
huahua1()
 { super("画画测试程序");
  setSize(600,600);
  setVisible(true);
 
  huabu=new cav();
  huabu.setBackground(Color.red);
 
  text=new TextField(40);
 
  p1=new Panel();
  p1.add(huabu);
  p1.add(text);
  add(p1);
 
  addMouseListener(this);
  addWindowListener(new shut());
 
 
  }
  //public void paint(Graphics g)
  //{ x=x+3;
  // g.drawOval(10,10,x,x);
  // }
 
  public static void main(String args[])
  { huahua1 fm=new huahua1();
 
  }
 
 


public void mousePressed(MouseEvent e)
  { text.setText("鼠标键按下了,位置是"+e.getX()+","+e.getY());
  repaint();
 
  }
  public void mouseReleased(MouseEvent e)
  { text.setText("鼠标松开了,位置是"+e.getX()+","+e.getY());  
  }
  public void mouseEntered(MouseEvent e)
  {text.setText("鼠标进来了,位置是"+e.getX()+","+e.getY());
 
 
  }
  public void mouseExited(MouseEvent e)
  { text.setText("鼠标走开了");
  }
  public void mouseClicked(MouseEvent e)
  { if(e.getClickCount()==2)
    text.setText("鼠标键双击,位置是"+e.getX()+","+e.getY());
    else{}
 
  }

}


class shut extends WindowAdapter
{ public void windowClosing(WindowEvent e)

System.exit(0);
}


}