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("涂鸦板");

}

}

相关文章:

  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2021-09-11
  • 2021-08-07
  • 2021-10-27
  • 2021-09-08
猜你喜欢
  • 2021-06-26
  • 2022-02-02
  • 2021-12-21
  • 2022-12-23
  • 2021-06-04
  • 2022-02-17
  • 2021-08-03
相关资源
相似解决方案