Basic of java applet
1. init() :-
called when an applet start execution.It is the first method called for any applet.
2. start() :-
called by the browser when an applet should start(or resume) execution. It is automatically called after init().
3. stop() :-
called by the browser to suspend execution of the applet. once stopped, an applet is restarted when the browser calls start().
4. destroy() :-
called by browser just before an applet is terminated.
Program:-
import java.applet.*;import java.awt.*;
import java.lang.*;
/*<applet code="applet2" height=200 width=300>
</applet> */
public class applet2 extends Applet
{
String msg;
public void init()
{
setBackground(Color.blue);
setForeground(Color.white);
msg=new String("--init ");
}
public void start()
{
msg=msg+"--start ";
}
public void paint(Graphics g)
{
g.drawString(msg,10,100);
}
public void stop()
{
msg=msg+" --stop ";
setBackground(Color.gray);
setForeground(Color.white);
}
}
Output:-
now minimize the java applet and restore it again
Comments