import java.awt.*;
import java.awt.event.*;
public class WriteApple extends Frame{
Graphics g;
public int startX,startY,endX,endY;
public WriteApple(String title){
super(title);
setVisible(true);
pack();
g=this.getGraphics();
addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent e){
startX=e.getX();
startY=e.getY();
}
});
addMouseMotionListener(new MouseMotionAdapter(){
public void mouseDragged(MouseEvent e){
endX=e.getX();
endY=e.getY();
g.drawLine(startX,startY,endX,endY);
startX=endX;
startY=endY;
}
});
}
public static void main(String[] args) {
Frame f=new WriteApple("涂鸦板");
}
}