Program to draw shape of rectangle, circle and oval with different color
Program:
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
/*
<applet code="colordraw.class"
HEIGHT=1000 WIDTH=1000>
</applet>
*/
public class colordraw extends Applet
{
public void paint(Graphics g)
{
g.setColor(Color.green);
g.drawRect(20,20,800,600);
g.setColor(Color.yellow);
g.drawOval(70,70,500,500);
g.setColor(Color.blue);
g.drawOval(120,120,50,90);
}
}
Output:
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
/*
<applet code="colordraw.class"
HEIGHT=1000 WIDTH=1000>
</applet>
*/
public class colordraw extends Applet
{
public void paint(Graphics g)
{
g.setColor(Color.green);
g.drawRect(20,20,800,600);
g.setColor(Color.yellow);
g.drawOval(70,70,500,500);
g.setColor(Color.blue);
g.drawOval(120,120,50,90);
}
}
Output:
Comments
Post a Comment