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.
Please up vote ,comment if any query . Thanks for Question . Be safe .
Note : check attached image for output .
Program : *******************JavaApplet.java****************************
import java.awt.Graphics;
import java.applet.Applet;
import java.awt.Color;
import java.awt.Font;
public class JavaApplet extends Applet
{
public void paint (Graphics g) //paint function called
automatically
{
this.setSize(200, 200); //set applet windows
size 200,200(WIDHT ,HEIGHT)
Font bigBoldFont = new Font("Arial",
Font.BOLD, 24); //set font Arial ,bold ,24
setForeground(Color.yellow); //set circle draw
color yello
g.fillRoundRect(0, 0, 90, 90, 200, 200); //draw
rectange at x=0,y=0 ,width ,height ,arc width ,archeight
g.setFont(bigBoldFont);//set bold font
g.setColor(Color.BLACK); //font color
black
g.drawString("GO",25,50);
//draw GO string inside circle
}
}
Applet Output :
Please comment if any query .