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 find the below java program to write a text inside circle.
import java.applet.*;
import java.awt.*;
public class app extends Applet {
public void paint(Graphics g) { // Gives the canvas for creating
graphics 'g'
setForeground(Color.yellow); // We can set the color
for any shapes like this or using setColor() method
g.fillRoundRect(50, 50, 90, 90, 200, 200);
// created a circle ; 50, 50: It is the leftmost point , 90,90:
Height and width , 200,200 : arrcwidth and archeight
// font object is created and the styling for
proceeding shape is specified
Font f = new Font("Arial", Font.BOLD, 24);
g.setColor(Color.black);
g.setFont(f);
g.drawString("GO", 75, 100); // the coordinates of
string is specified in the way that it falls inside circle
}
}
Please run the code and you will get a circle with text inside it.