How to create an circle using Applet :
type the given program or copy paste to note pad
Circle.java
import java.applet.*;
import java.awt.*;
/*
*/
public class circle extends Applet
{
public void init()
{
setBackground(Color.yellow);
setForeground(Color. red);
Font f;
f=new Font("Courier",Font.PLAIN+Font.BOLD,20);
setFont(f);
}
public void paint(Graphics g)
{
int x=350,y=25,w=80,h=80;
g.drawString("Circle",450,400);
g.drawOval(x,y,w,h);
g.drawOval(450,28,120,120);
g.drawOval(600,18,150,150);
showStatus("Draw a CIRCLE using Polymorphism and
lnheritance:");
}
}
Output:
D:\ur folder\javac circle
D:\ur folder\appletviewer circle.java
No comments:
Post a Comment