📄 draw3.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 + -