Java-Stop and Destroy

Stop

The stop( ) method is called by the web browser or the appletviewer to suspend the execution of an applet. When a user switches over from a web page that contains the applet to another web page, the execution of that web page will be suspended. Remember that the stop( ) method will be called by the appletviewer or the web browser whenever the execution of an applet is to be suspended.

destroy

The destroy( ) method is called by the appletviewer or the web browser just before the execution of an applet is terminated. When we quit the appletviewer or the web browser itself, the destroy() method of the applet that is currently executed will be called.

Program

dfgdfgdfd

Program Source

import java.applet.Applet;
import java.awt.Graphics;
import javax.swing.JOptionPane;

public class Javaapp extends Applet {
   
    public void init()
    {
        JOptionPane.showMessageDialog(null,"Applet : Initialized");
    }
    
    public void start()
    {
        JOptionPane.showMessageDialog(null,"Applet : Started");
    }
    
    public void stop()
    {
        JOptionPane.showMessageDialog(null,"Applet : Stopped");
    }
    
    public void paint(Graphics g)
    {
        
        g.drawString("Applet : Running", 100, 100);
    }
    
    public void destroy()
    {
        JOptionPane.showMessageDialog(null,"Applet : Destroyed"); 
    }
}

Leave a Comment