Saturday, 13 September 2014

Applet in Java

//Program For Shapes in Applet
import java.awt.*;
import java.applet.*;
public class ShapesDemo extends Applet
{
    public void paint(Graphics g)
    {
        g.drawLine(10,10,110,110);
        g.drawRect(160,10,100,100);
        g.drawOval(310,10,100,100);
        g.drawArc(10,160,90,50,200,150);
    }
}

/*


*/
Output


//Program for Polygon in Applet
import java.awt.*;
import java.applet.*;
public class PolygonDemo extends Applet
{
    public void paint(Graphics g)
    {
        int x[] = {10,10,110};
        int y[] = {10,110,110};
        int n = 3;

        g.drawPolygon(x,y,n);
    }
}

/*


*/
Output


//Program for Face in Applet
import java.applet.*;
import java.awt.*;

public class Face_Applet extends Applet
{
    public void paint(Graphics g)
    {
        g.drawOval(50,50,200,200);

        g.drawOval(100,100,25,25);
        g.fillOval(100,100,25,25);

        g.drawOval(180,100,25,25);
        g.fillOval(180,100,25,25);

        g.drawArc(110,170,90,50,200,150);
    }
}

/*


*/
Output

No comments:

Post a Comment