1 画圆弧
package Swing;
import java.applet.Applet;
import java.awt.Graphics;
public class DrawArc extends Applet
{
public void paint(Graphics g)
{
int x=30,y=20;
int width=100,height=200;
int startAngle=90,arcAngle=190;
g.drawArc(x, y, width, height, startAngle, arcAngle);
}
}
package Swing;
import java.applet.Applet;
import java.awt.Graphics;
public class DrawArc extends Applet
{
public void paint(Graphics g)
{
int x=30,y=20;
int width=100,height=200;
int startAngle=90,arcAngle=190;
g.drawArc(x, y, width, height, startAngle, arcAngle);
}
}
2画直线
package Swing;
import java.applet.Applet;
import java.awt.Graphics;
public class DrawLine extends Applet
{
public void paint(Graphics g)
{
int x1=0,y1=0;
int x2=100,y2=100;
g.drawLine(x1,y1, x2, y2);
}
}
3画圆
package Swing;
import java.applet.Applet;
import java.awt.Graphics;
public class DrawOval extends Applet
{
public void paint(Graphics g)
{
int x=20,y=20;
int width=60,height=100;
g.drawOval(x, y, width, height);
}
}
4 画多边形
package Swing;
import java.applet.Applet;
import java.awt.Graphics;
public class DrawPolygon extends Applet
{
public void paint(Graphics g)
{
int x[]={50,88,78,100};
int y[]={20,35,88,97};
int n=4;
g.drawPolygon(x,y,n);
}
}
5画出直角矩形和圆角矩形
package Swing;
import java.applet.Applet;
import java.awt.Graphics;
public class DrawRectandRoundRect extends Applet
{
public void paint(Graphics g)
{
int x1=50,y1=20;
int width1=50,height1=50;
int width2=20,height2=20;
g.drawRect(x1, y1, width1, height1);
g.drawRoundRect(x1+50, y1+50, width1, height1, width2, height2);
}
}