0% found this document useful (0 votes)
11 views7 pages

Experiment 28

The document describes three Java applet programs. The first displays a welcome message. The second implements all applet methods like init(), start(), stop(), and destroy(). It prints messages for each. The third uses a for loop to draw five rounded rectangles across the screen.

Uploaded by

rjadha72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Experiment 28

The document describes three Java applet programs. The first displays a welcome message. The second implements all applet methods like init(), start(), stop(), and destroy(). It prints messages for each. The third uses a for loop to draw five rounded rectangles across the screen.

Uploaded by

rjadha72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

EXPERIMENT 28

Aim: Develop minimum two basic Applets. Display output with applet
viewer and browser.

a) Develop a program on basic applet.

b) Develop a program using control loops in applets

Program 1: Develop a basic applet to display "Welcome to the World of


Applet".

//Exp28.java

import java.applet.Applet;

import java.awt.*;

public class Exp28 extends Applet

public void paint(Graphics g)

Font font = new Font("Arial", Font.BOLD, 20);

g.setFont(font);

g.drawString("Welcome to the Java Applets....", 50,50);

}
//Exp28.html

<html>

<head>

<title>Basic Applet</title>

</head>

<body>

<applet code="Exp28.class" width="300" height="200">

<applet>

</body>

</html>

Output:
Program 2: Develop a program to implement all methods of applet.

//Exp28_1.java

import java.applet.Applet;

import java.awt.*;

public class Exp28_1 extends Applet

public void init()

System.out.println("\nInitializing applet...");

public void start()

System.out.println("\n Starting applet...");

public void stop()

System.out.println(" Stopping applet...");

public void destroy()

System.out.println("\nDestroying applet...");

}
public void paint(Graphics g)

Font font = new Font("Arial", Font.BOLD, 20);

g.setFont(font);

System.out.println(" Painting applet...");

g.drawString("Welcome to Applet Methods", 20, 20);

//Exp28_1.html

<html>

<head>

<title>All Methods of Applet</title>

</head>

<body>

<applet code="Exp28_1.class" width="300" height="300">

</applet>

</body>

</html>
Output:
Program 3: Develop a program using control loops in applets.

//Exp28_2.java

import java.applet.Applet;

import java.awt.*;

public class Exp28_2 extends Applet

public void paint(Graphics g)

int x = 20, y = 20;

for (int i = 0; i < 5; i++)

g.drawRoundRect(x, y, 50, 50, 10, 10);

x += 70;

//Exp28_2.html

<html>

<head>

<title>Control Loops in Applet</title>

</head>
<body>

<applet code="Exp28_2.class" width="300" height="300">

</applet>

</body>

</html>

Output:

You might also like