Applet Life Cycle
Applet life cycle consists of 5 methods which will be automatically invoked by JRE when some action is done on the application/browser.
List of Methods:
- public void init()
- public void start()
- public void stop()
- public void destroy()
- public void paint(Graphics g)
Which method will be invoked when?
init()
- Invoked only once
- Invoked when the application is launched using appletviewer or browser
- Should include code for component defination, Object creation, Layout settings, Basic look and feel
start()
- Invoked when application is maximized
- Default application state is Maximized window so this will also be invoked on launching
- Should include code for starting/resuming thread, starting/resuming Graphical User Interface, etc…
stop()
- Invoked when application is minimized
- invoked also when the window is terminated while its in maximizes state.
- Should include code for pausing/stopping thread, pausing/stopping Graphical User Interface, etc…
destroy()
- Invoked when application is about to terminate
- invoked when we close the application.
- Should include code for connection closing, file closing, etc…
paint()
- Invoked when application is to be refreshed in terms of GUI
- invoked when we start, move or resize applet.
- Should include code for GUI design
Some method calling scenarios:
On Launching an Applet application: init(), start(), paint()
On Minimizing an Applet application: stop()
On Maximizing an Applet application: start(), paint()
On Moving/Re-sizing an Applet application: paint(), paint(), …, paint()
On Terminating an Applet application: stop(), destroy()
Recent Comments