Java: Applet and Application [Reserved]

xiaoxiao2021-03-06  111

1. Applet: The Java applet running in a web browser that supports Java. ?????? The browser initializes and launches the Applet program for the web page; when we do not need to display the web page, the browser will start the corresponding method to terminate the operation of the Applet program. 1.1 The following four methods control the operation of Applet: (1) INIT () When opening a document with Applet, call the init () method to initialize Applet (2) start ()? When opening a document with Applet, After the init () method, the start () method is called, starting the applet (3) stop () • Turn off the document with Applet. Note: STOP () always calls (4) DESTROY () when the Destroy () method is called. Turn off the browser. Calls destroy () is to organize resources have been used a simple applet example: //StarterApplet.javaimport java.applet.Applet; import java.awt.Label; public class StarterApplet extends Applet {private Label label; public void init () {System.out.println ("applet :: init ()");} public void start () {system.out.println ("applet :: start ()"); label = new label ("starter"); Add (Labl);} public void stop () {system.out.println ("applet :: stop ()"); remove (label);} public void destroy () {system.out.println ("applet :: Destroy () ");}} 1.2 To update the Java.awt.comPonent's display mode uses the following three methods: Paint ()? Drawing the component repaint ()? Call Update ()? heavy as early as possible Painting components, the default scheme is refreshing screen and calls the Paint method 2.java application: Run in the Java interpreter ?? Difference to Applet: ?? (1) Java application must have main () method? (2) The Java application needs to have a window, it must extend the AWT Frame class? (3) Java application does not have the same security constraint as an applet: //starterapplication.javaimport java.awt.event; import java.awt.Frame; import java.awt.event *;. import java.awt.Label;? public class StarterApplication extends Frame {public static void main (String args []) {StarterApplication app = new StarterApplication ( "Starter Application "); app.sets Ize (300, 100); app.show (); system.out.println ("starterapplication :: main ()");}

转载请注明原文地址:https://www.9cbs.com/read-125278.html

New Post(0)