Slip No 26 Q B

Q.Write a java program using applet to draw Temple. [25 M]

import java.applet.Applet;
import java.awt.*;

public class TempleApplet extends Applet
{
    public void paint(Graphics g)
    {
        // Temple Base
        g.setColor(Color.ORANGE);
        g.fillRect(150, 150, 200, 120);

        // Temple Roof (Triangle)
        int x[] = {130, 250, 370};
        int y[] = {150, 60, 150};
        g.setColor(Color.RED);
        g.fillPolygon(x, y, 3);

        // Door
        g.setColor(Color.DARK_GRAY);
        g.fillRect(220, 200, 60, 70);

        // Steps
        g.setColor(Color.GRAY);
        g.fillRect(180, 270, 140, 20);
        g.fillRect(160, 290, 180, 20);

        // Flag pole
        g.setColor(Color.BLACK);
        g.drawLine(250, 60, 250, 30);

        // Flag
        int fx[] = {250, 280, 250};
        int fy[] = {30, 40, 50};
        g.setColor(Color.GREEN);
        g.fillPolygon(fx, fy, 3);

        // Sun
        g.setColor(Color.YELLOW);
        g.fillOval(30, 30, 50, 50);
    }
}
HTML File to Run Applet
<html>
<body>
<applet code="TempleApplet.class" width="500" height="350"></applet>
</body>
</html>
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top