⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 draw3.java

📁 《Java编程基础、应用与实例》 源文件下载
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
public class Draw3 extends Frame{
  Graphics g;
  int x,y, ox, oy;
  public Draw3(String title){
    super(title);
    setSize(200,200);
    setVisible(true);
    g=this.getGraphics();
    g.setColor(Color.red);
    addMouseMotionListener(new MouseMotionAdapter(){
        public void mouseDragged(MouseEvent e){
          x=e.getX(); y=e.getY();
          g.drawLine(ox, oy, x, y);
          ox=x; oy=y;
        }
    });
    addMouseListener(new MouseAdapter(){
        public void mousePressed(MouseEvent e){
           ox=e.getX(); oy=e.getY();
        }
    });
  } 
  public static void main(String[] args){
    Frame f=new Draw3("档屈 弊府扁");
 
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -