Applet Life cycle and How to Handle Event in Applet in Core Java

In this tutorial Applet Life cycle is explained and how to handle event in Applet in Core Java is shown.


/*<applet code=”MyApplet” height=”400″ width=”400″> </applet>*/

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;

public class MyApplet extends Applet
Button b;
Label l;
TextField t;

public void init()
b = new Button(“OK”);
l = new Label(“Enter your name:”);
t = new TextField(30);


b.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
JOptionPane.showMessageDialog(null,”Hello “+t.getText(),”MESSAGE”,JOptionPane.INFORMATION_MESSAGE);


System.out.println(“Inside init”);

public void start()
System.out.println(“Inside start”);

public void stop()
System.out.println(“Inside stop”);

public void destroy()
System.out.println(“Inside destroy”);

public void paint(Graphics g)


Add a Comment

Your email address will not be published. Required fields are marked *