In: Computer Science
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.
Program:
import java.awt.*;
import java.applet.*;
/*
<applet code="CircleDemo" height=350 width=450>
</applet>
*/
public class CircleDemo extends Applet
{
public void paint(Graphics g)
{
//Color class with its constructor value to get Yellow color
(255,255,0)
Color c1=new Color(255,255,0);
//set color to filled circle by using setColor() method
g.setColor(c1);
//creating filled circle using fillOval() method that has 4
parameters
//fillOval(x,y,width,height)
g.fillOval(100,50,250,250);
//setting font style, Bold text, size using Font class
Font f1=new Font("Arial",Font.BOLD,24);
//setting font using setFont() method
g.setFont(f1);
Color c2=new Color(0,0,0);
g.setColor(c2);
//printing text using drawString(str, x, y) method
g.drawString("GO",210,180);
}
}
Output: