📄 lineapp.java
字号:
import java.applet.Applet;
import java.awt.*;
class aLine {
int startX;
int startY;
int endX;
int endY;
Color lineColor;
public aLine(int sx,int sy,int ex,int ey,Color clr)
{
startX = sx;
startY = sy;
endX = ex;
endY = ey;
lineColor = clr;
}
public void draw(Graphics g)
{
g.setColor(lineColor);
g.drawLine(startX, startY, endX, endY);
}
};
public class LineApp extends Applet {
int initCount = 0;
int startCount = 0;
int stopCount = 0;
int destroyCount = 0;
static int drawIndex = 0;
static aLine drawList[] = new aLine[500];
public void paint(Graphics g){
g.setColor(Color.white);
g.fillRect(0,0,size().width,size().height);
for (int i=0; i<drawIndex; i++)
drawList[i].draw(g);
}
public void drawLine(int sx, int sy, int ex, int ey, int clr)
{
drawList[drawIndex] = new aLine(sx,sy,ex,ey, Color.red);
drawIndex++;
repaint();
}
public void clearAll()
{
drawIndex = 0;
repaint();
}
public void update(Graphics g) {
paint(g);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -