Converting between applets and applications

Source: Internet
Author: User
Tags constructor header html page window
Application converting between applets and Applicationsto convert a application to applet:create an HTML page with a Pplet tag to invoke the applet. Delete the Main method. Alter the class header so that it extends Applet rather than Frame. ADD the import for the library class Applet. Change the name of the ' constructor method ' from the ' name of ' class to init. Add an invocation of the "a" to set the "layout of widgets in the applet window." This is typically:setlayout (new BorderLayout ()); To convert a applets to application:change the name of the Init method to the name of the class. This is the constructor method for the class. Delete the word void in the header for this method and since a constructor method has no return type. Alter the class header so that it extends Frame rather than Applet. Create a new method called Main, with the header public static void main (string[] args) .  This is now the constructor Method should create a Frame object as a instance of the class. So, if the class is called MyClass, the Main method should be:public static void Main (string[) args) {    Ass f = new MyClass ();    f.setsize;    f.setvisible (true); Delete the import for the class Applet and since it now redundant. Add a method windowclosing to handle the event which was the user clicking on the Close Window button. This is also involves adding implements WindowListener and This.addwindowlistener (this); In order to register the event handler. Add an invocation of the "a" to set the layout of widgets in the frame. This is typically:setlayout (new FlowLayout ()); Make sure this applet does not with any of the methods that are special to the applet class-methods including Oclip, GetCodeBase, Getdocumentbase, getimage. 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.