Java Example Program / Sample Source Code
import java.applet.*;
import java.awt.*;
public class ShapesApplet extends Applet {
public void paint(Graphics g) {
int xa[] = { 120, 125, 150, 150, 200, 200 };
int ya[] = { 175, 100, 100, 175, 175, 200 };
// draws String
g.drawString("This is Shapes Example", 100, 20);
// draws a Line
g.drawLine(90, 135, 90, 180);
// draws a Oval
g.drawOval(0, 10, 100, 100);
// draws a Rectangle
g.drawRect(190, 50, 100, 100);
// fill an Arc
g.fillArc(70, 150, 100, 100, 0, -90);
// draws a Polygon
g.drawPolygon(xa, ya, 6);
}
} |
|
|