Question

In: Computer Science

Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...

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.  

Solutions

Expert Solution

There are two standard ways in which you can run an applet :

  1. Executing the applet within a Java-compatible web browser.
  2. Using an applet viewer, such as the standard tool, applet-viewer. An applet viewer executes your applet in a window. This is generally the fastest and easiest way to test your applet.

first approach:-

//this is HelloWorld.java program

// A Hello World Applet
// Save file as HelloWorld.java
  
import java.applet.Applet;
import java.awt.Graphics;
  

// HelloWorld class extends Applet
public class HelloWorld extends Applet
{
// Overriding paint() method
@Override
public void paint(Graphics g)
{
s.setColor(Color.YELLOW);
s.fillOval(50, 50, 100, 100);
Font f = new Font("Arial", Font.BOLD, 24);
g.setFont(f);
g.setColor(Color.GREEN);
s.drawString("GO", 60, 75);
}
  
}

//this is HelloWorld.html file

<html><body>

<applet code=HelloWorld width=500 height=500></applet>

</body></html>

With this approach, first compile HelloWorld.java file and then simply run below command to run applet :-

appletviewer HelloWorld.html

second approaach:-

//this is HelloWorld.java file

import java.applet.Applet;
import java.awt.Graphics;
  
/*
<applet code="HelloWorld" width=200 height=60>
</applet>
*/
  
// HelloWorld class extends Applet
public class HelloWorld extends Applet
{
// Overriding paint() method
@Override
public void paint(Graphics g)
{
s.setColor(Color.YELLOW);
s.fillOval(50, 50, 100, 100);//this will form a yellow color circle
Font f = new Font("Arial", Font.BOLD, 24);
g.setFont(f);
g.setColor(Color.GREEN);
s.drawString("GO", 60, 75);//this will write a green string on applet inside the circle
}
  
}
  

With this approach, first compile HelloWorld.java file and then simply run below command to run applet :-

appletviewer HelloWorld

Related Solutions

Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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 within 25 min plzzz
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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. I need this answer ASAP PLZ.
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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.
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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.  
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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.
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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.
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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.
Write an applet in Java that creates a yellow colored filled circle on screen. Inside this...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT