Thursday, June 3, 2021

Design an JAVA Applet to display the Sum of Two Numbers and set status message in Applet window.

PROGRAM :

package com.company;

import java.awt.*;

import java.applet.*;

/* <applet code = Applet1.class width= 200 height=200></applet> */

public class Applet1 extends Applet

{

    public void paint(Graphics g)

    {

        setBackground(Color.green);

        int a=100;

        int b=200;

        int sum = a+b;

        String s = "The Sum is :" + String.valueOf(sum);

        g.drawString( s, 200,100);

        showStatus("This is a status message of an applet window");

    }

}

OUTPUT :



Labels: ,