Application to Applet Migration
Following steps can be noticed in the above program to develop an applet instead of application.
- Import java.applet package
- Extend Applet instead of Frame
- Write init() method in place of constructor
- No main() method
- Write an extra HTML file to run the applet
- No set methods like setSize() as they are given in HTML file
- No window closing code as window closing is implicit
Remember the default layout manager for Applet is FlowLayout which can be changed (like BorderLayout for Frame). In the above program, the default FlowLayout is used.
Note: In applet, window closing code is not required. It is automatic.
Note: User's selection, messages or component information etc. can be displayed in five ways. In this program, it is displayed as a Label component.