Java applet program that displays a simple message

Week 8

Java applet program that displays a simple message

  1. Aim: To Develop an applet that displays a simple message.

In this example, we are using a function named g.drawString () which is a method of Graphics class, here g is an object of Graphics class. drawString () is taking three parameters string to display and x, y co-ordinates.

Source Code:

/* Develop an applet that displays a simple message( information ) */

import java.awt.*;

import java.applet.*;

/*<applet code=weeka height=400 width=400>

</applet> */

class weeka extends Applet

{

 public static void init()

 {

  setForeground(Color.yellow);

 }

 public static void paint(Graphics g)

 {

  g.drawString(” Hello World “,80,40);

 }

}

Expected Output

Java applet program that displays a simple message

https://www.w3schools.in/java-tutorial/java-applets/

https://en.wikipedia.org/wiki/Java_applet

Leave a Comment

Your email address will not be published. Required fields are marked *