Convert Applet to Application

Convert Applet to Application

After knowing the differences between applets and applications and Applet cum Application, let us see how to convert an Applet to Application. For this, best one is a GUI applet.
Following program is an applet and later converted to an application. Then, steps of conversion of Applet to Application are listed.

Following applet changes the background of the window as per the button clicked.

HTML file to execute the above applet

Now let us change the above Applet to Application .

Following is the application obtained after converting the Applet to Application.

Following are the changes to be made from Applet to Application

1. Delete the statement "import java.applet" package
2. Replace extends Applet with Frame
3. Replace the init() method with constructor
4. Check the layout (for Applet, the default layout is FlowLayout and for Frame, it is BorderLayout)
5. Add setXXX() methods like setSize() etc.
6. Add the main() method
7. HTML is not required (delete it)

Leave a Reply

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