import java.awt.Graphics;
import java.awt.Polygon;
import java.applet.Applet;
public class ZeichnePolygon2 extends Applet {
// Definiere ein Array mit X-Koordinaten
int[] xCoords = { 10, 40, 60, 300, 10, 30, 88 };
// Definiere ein Array mit Y-Koordinaten
int[] yCoords = { 20, 0, 10, 60, 40, 121, 42 };
// Bestimme Anzahl Ecken über Methode length
// des Array-Objekts mit x-Koordinaten
int anzahlEcken = xCoords.length;
public void paint(Graphics g) {
Polygon poly = new Polygon(xCoords, yCoords, anzahlEcken)
// Zeichne ein 7-Eck
g.drawPolygon(poly);
}
}
Hier ist der Bereich, in dem das Applet zeichnen darf:
Und hier geht es wieder weiter auf der Seite.