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

Have any Question or Comment?

Leave a Reply

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

Categories

You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.