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

***Creating Shapes in Applet***


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

public class  ShapColor extends Applet
{
  int x=300,y=100,r=50;

  public void paint(Graphics g)
  {
  g.setColor(Color.red);  //Drawing line color is red
  g.drawLine(3,300,200,10);
  g.setColor(Color.magenta);
  g.drawString("Line",100,100);

  g.drawOval(x-r,y-r,100,100);
  g.setColor(Color.yellow);  //Fill the yellow color in circle
  g.fillOval( x-r,y-r, 100, 100 );
  g.setColor(Color.magenta);
  g.drawString("Circle",275,100);
 
  g.drawRect(400,50,200,100);
  g.setColor(Color.yellow);  //Fill the yellow color in rectangel
  g.fillRect( 400, 50, 200, 100 );
  g.setColor(Color.magenta);
  g.drawString("Rectangle",450,100);
  }
}


No comments: