In: Computer Science
URGENT!!!!!!!!!!!!!!!!!!!!
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this circle the word “GO” with Arial font and size 24, bold face needs to be printed. Justify your syntax.
For creating this application ,first create a java file named DrawCircl.java with following code,then run applet based on any following methods
DrawCircl.java file
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class DrawCircl extends Applet{
public void paint(Graphics g){
//set color to yello
setForeground(Color.yellow);
//draw a filled oval using fillOval(int x1,int y1, int width,
int height) method of Graphics class.
//draw filled oval
g.fillOval(20,20,100,100);
//printing of string “GO” with Arial font and size 24, bold
face
g.setColor(new Color(0, 100, 0));
g.setFont(new Font("Areal", Font.BOLD, 24));
g.drawString("GO", 20, 20);
}
}
Compilation Steps
1) Using appletviewer
javac DrawCircl.java
appletviewer DrawCircl.class
2)Using web browser
javac DrawCircl.java
create html file as follows
circle.html
<html> <head> <title>Circle Applet</title> </head> <body> <applet code="DrawCircl.class" height="250" width="250"> </applet> </body> </html>