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

Hi, I’m Pramod Kumar Yadav & a computer science Engineer with 3years of experience in Digital marketing. I’m self-motivated and love to do SEO.

Leave a Reply

%d bloggers like this: