|
Figuren Beispiel 1: import java.awt.*; public class Figu01 extends java.applet.Applet { public void paint(Graphics g) { g.drawRect(50,50,400,200); g.drawRect(80,60,100,50); g.setColor(Color.red); g.fillRect(200,60,100,50); g.setColor(Color.green); g.fillRect(320,60,100,50); g.setColor(Color.black); g.drawOval(80,125,100,50); g.setColor(Color.cyan); g.fillOval(225,125,50,50); g.setColor(Color.pink); g.fillOval(320,125,100,50); g.setColor(Color.black); g.drawRoundRect(80,190,100,50,20,20); g.setColor(Color.yellow); g.fillRoundRect(200,190,100,50,40,40); g.setColor(Color.blue); g.fillRoundRect(320,190,100,50,100,50); } } Beispiel 2: import java.awt.*; public class Figu02 extends java.applet.Applet {
public void paint(Graphics g)
{
g.drawRect(50,50,400,200);
g.setColor(Color.green);
for(int i=60;i<=240;i+=10)
g.drawLine(60,i,440,i);
for(int i=60;i<=440;i+=10)
g.drawLine(i,60,i,240);
g.setColor(Color.red);
Polygon pg1 = new Polygon();
pg1.addPoint(80,80);
pg1.addPoint(100,120);
pg1.addPoint(140,120);
pg1.addPoint(180,80);
g.drawPolygon(pg1);
Polygon pg2 = new Polygon();
pg2.addPoint(280,80);
pg2.addPoint(260,120);
pg2.addPoint(340,120);
pg2.addPoint(420,80);
g.fillPolygon(pg2);
g.drawArc(80,160,100,60,0,360);
g.drawArc(200,160,100,60,30,270);
g.fillArc(320,160,100,60,30,270);
}
}
|
|
|