import java.applet.Applet;
import javax.swing.*;
import java.awt.*;
import java.awt.Dimension;
public class AppletDrawDemo extends Applet {
public void init() {try
{
this.setSize(new Dimension(569, 167));
jbInit();
}catch (Exception e){
e.printStackTrace();
}
}
private void jbInit() throws Exception {
repaint();
}
public void paint (Graphics g){
int gridWidth=600/6;
int gridHeight=250/2;
int rowspacing=5;
int columnspacing=7;
int rectWidth=gridWidth-columnspacing;
int rectHeight=gridHeight-rowspacing;
g.drawRect(80, 80, 605 -1, 265);//请问这里的数字是什么意思呀?
int x=85;
int y=87;
g.drawLine(x, y+rectHeight-1, x+rectWidth, y);
x+=gridWidth;
g.drawRect(x, y, rectWidth, rectHeight);
x+=gridWidth;
g.drawRoundRect(x, y, rectWidth, rectHeight, 10, 10);
x+=gridWidth;
g.drawArc(x, y, rectWidth, rectHeight, 90, 135););//请问这里的数字是什么意思呀?
x+=gridWidth;//弧形
g.drawOval(x, y, rectWidth, rectHeight);
x+=gridWidth;//椭圆形
//封闭多边行
int x1Points[]={x,x+rectWidth,x,x+rectWidth};//这两句有什么作用呀?
int y1Points[]={y,y+rectHeight,y+rectHeight,y};
g.drawPolygon(x1Points,y1Points,4);
x=85;
y+=gridHeight;
//开放多边行
int x2Points[]={x,x+rectWidth,x,x+rectWidth};//这两句有什么作用呀?
int y2Points[]={y,y+rectHeight,y+rectHeight,y};
g.drawPolyline(x2Points,y2Points,4);
x+=gridWidth;
g.setColor(Color.blue);
g.fillRect(x, y, rectWidth, rectHeight);
x+=gridWidth;
g.fillRoundRect(x, y, rectWidth, rectHeight, 10, 10);//这里的两个10有什么用处吗?
x+=gridWidth;
//填充弧形
g.fillArc(x, y, rectWidth, rectHeight, 90, 135);
x+=gridWidth;
g.fillOval(x, y, rectWidth, rectHeight);
x+=gridWidth;
//封闭多边行
int x3Points[]={x,x+rectWidth,x,x+rectWidth};//这两句有什么作用呀?
int y3Points[]={y,y+rectHeight,y+rectHeight,y};
g.fillPolygon(x3Points, y3Points, 4);
}
}