import javaawtColor;
import javaawtFrame;
import javaawtGraphics;
import javaawtPoint;
import javaawteventMouseAdapter;
import javaawteventMouseEvent;
import javaawteventMouseListener;
import javautilArrayList;
import javautilIterator;
public class MyMouseAdapter {
public static void main(String[] args) {
new MyFrame(drawing);
}
}
class MyFrame extends Frame{
ArrayList points=null;
MyFrame(String s){
super(s);
points=new ArrayList();
setLayout(null);
setBounds();
thissetBackground(new Color());
setVisible(true);
thisaddMouseListener(new Monitor());
}
public void paint(Graphics g){
Iterator i=erator();
while(ihasNext()){
Point p=(Point)inext();
gsetColor(Colorblue);
gfillOval(pxpy );
}
}
public void addPoint(Point p){
pointsadd(p);
}
}
class Monitor extends MouseAdapter{ //MouseAdapter实现了MouseListener接口
public void mousePressed(MouseEvent e){
MyFrame f=(MyFrame)egetSource();
faddPoint(new Point(egetX()egetY()));
frepaint(); //让Frame强制经行重画
}
}