Java AppletApplet is a special type of program that is embedded in the webpage to generate the dynamic content. It runs inside the browser and works at client side. Advantage of AppletThere are many advantages of applet. They are as follows:
Drawback of Applet
Hierarchy of Applet
Lifecycle of Java Applet
Lifecycle methods for Applet:The java.applet.Applet class 4 life cycle methods and java.awt.Component class provides 1 life cycle methods for an applet. java.applet.Applet classFor creating any applet java.applet.Applet class must be inherited. It provides 4 life cycle methods of applet.
java.awt.Component classThe Component class provides 1 life cycle method of applet.
Who is responsible to manage the life cycle of an applet?Java Plug-in software. How to run an Applet?There are two ways to run an applet
Simple example of Applet by html file:To execute the applet by html file, create an applet and compile it. After that create an html file and place the applet code in html file. Now click the html file. Note: class must be public because its object is created by Java Plugin software that resides on the browser.myapplet.htmlSimple example of Applet by appletviewer tool:To execute the applet by appletviewer tool, create an applet that contains applet tag in comment and compile it. After that run it by: appletviewer First.java. Now Html file is not required but it is for testing purpose only. To execute the applet by appletviewer tool, write in command prompt: c:/>javac First.java c:/>appletviewer First.java |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/263795.html