Program for Demonistrating LIFE CYCLE OF APPLET

import java.awt.*; import java.applet.Applet; import java.awt.event.*; import java.applet.*; public class App extends Applet imple...

import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.applet.*;
public class App extends Applet implements ActionListener
{
            TextField text1,text2,ans;
            Label plus;
            Button bt;
            public void init()
            {
                        text1=new TextField();
                        text2=new TextField();
                        ans=new TextField();
                        plus=new Label("+");
                        bt=new Button("=");
                        bt.addActionListener(this);
                        add(text1);
                        add(plus);
                        add(text2);
                        add(bt);
                        add(ans);
            }
            public void actionPerformed(ActionEvent e)
            {
                        if(e.getSource()==bt)
                        {
int sum=Integer.parseInt(text1.getText())+Integer.parseInt(text2.getText());
                                    ans.setText(String.valueOf(sum));
           
                        }
            }
}

APPLET.HTML

<html>
<head>
<title> APPLET</title>
</head>
<body bgcolor="yellow">

<applet code="App" width="200" height="300"/>
</body>
</html>


OUTPUT:

applet

Related

Java 5099291993725710146

Post a Comment

emo-but-icon

item