?? 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 + -