Java applet program that displays a simple message

Write an applet that displays a simple message

  1. import java.awt*;
  2. import java.applet.*;
  3. Create applet frame in under comment
    1. /*<applet code=weeka height=400 width=400> </applet>*/
  4. Create Class Weeka extends Applet
  5. Setforeground(Color.yellow)
  6. public static void paint(Graphics g)
  7. g.drawString(“Hellow World”,size of text x, size y)

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 coordinates.

Source Code To print Simple Message using applet

/* 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 to display simple message
  • A simple java applet program to display a text
  • java applet program to display a simple message
  • Java applet program to display text
  • Write a java applet program to print some text
  • Write a program using the label to display the message welcome to java
    develop a program using the label to display message welcome to java
  • How to run applet program in java
  • Algorithm for applet program
  • write an applet to display a simple message on a colored background

Recommended Post:

Find the solution to the salesforce Question and many more

Pramod Kumar Yadav is from Janakpur Dham, Nepal. He was born on December 23, 1994, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India. Pramod has worked as the owner of RC Educational Foundation Pvt Ltd, a teacher, and an Educational Consultant, and is currently working as an Engineer and Digital Marketer.



Leave a Comment