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.
ANSWER :
Applet program to fill circle with yellow color and show text GO
import java.awt.*;
import java.applet.*;
import java.awt.Font;
import java.awt.Graphics;
public class circle extend Applet
{
public void paint(Graphics g)
{
g.drawOval(20,20,200,120);
g.setColor(Color.yellow);
g.fillOval(70,30,100,100);
}
}
/*
<applet code="CreateFont" width=200 height=200>
</applet>
*/
public class CreateFont extends Applet{
public void paint(Graphics g) {
Font myFont = new Font("Arial", Font.BOLD,24);
g.setFont(myFont);
g.drawString("GO", 10, 50);
}
}
HTML code:
<html>
<head>
</head>
<body>
<applet code = "circle.class" width = "600" height = "400"></applet>
</body>
</html>