About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Saturday, July 23, 2011

***A Simple Applet Program***


// -------------PersonApplet.java----------

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

public class PersonApplet extends Applet
{

        public void paint(Graphics g)
       {

// draw some people!
g.setColor(Color.red);
drawPerson(g, 50, 380, 200);
g.setColor(Color.cyan);
drawPerson(g, 100, 380, 200);
g.setColor(Color.blue);
drawPerson(g, 150, 380, 300);


}

private void drawPerson(Graphics g, int x, int y, int h)
       {

// Draw head (about a 1/4 of the height in proportion)
g.fillOval(x-h/8, y-h, h/4, h/4);

// Draw body
g.drawLine(x, y-3*h/4, x, y - h/4);

// Draw legs
g.drawLine(x, y-h/4, x-h/8, y);
g.drawLine(x, y-h/4, x+h/8, y);

// Draw arms
g.drawLine(x, y-5*h/8, x-h/8, y-3*h/4);
g.drawLine(x, y-5*h/8, x+h/8, y-3*h/4);

}

}



No comments: