Presentation is loading. Please wait.

Presentation is loading. Please wait.

Applet and Multimedia 2011.04.29. Outline Developing Applets Applet Life-Cycle Method Passing Strings to Applets [Sample code] DisplayLabel.html.

Similar presentations


Presentation on theme: "Applet and Multimedia 2011.04.29. Outline Developing Applets Applet Life-Cycle Method Passing Strings to Applets [Sample code] DisplayLabel.html."— Presentation transcript:

1 Java @Ch18. Applet and Multimedia 2011.04.29

2 Outline Developing Applets Applet Life-Cycle Method Passing Strings to Applets [Sample code] DisplayLabel.html + DisplayLabel.java DisplayMessage.html + DisplayMessage.java + MessagePanel.java Ball.java + BallControl.java + BounceBallApp.java + BounceBallApp.html

3 Developing Applets Every application must have a main method, which is invoked by the Java interpreter. Java applets do not need main method. They run in the Web browser environment. Every applet is a subclass of java.applet.Applet, the Applet class is an AWT class and is not designed to work with Swing components. (AWT : Abstract Windows Tookits, 包裹於 java.awt.* 所有 AWT 元件皆繼承自 java.awt.Component )

4 ( 課本 P.639)

5 程式範例 :  DisplayLabel.html + DisplayLabel.java

6 Applet Life-Cycle Method Applets are actually run from the container. Applet class contains the init(), start(), stop(), destroy() methods.

7 Passing Strings to Applets Pass strings to Java applets, a parameter must be declared in the HTML file and must be read by the applet when it is initialized. Parameters are declared using the tag. To read the parameter from the applet, use the following method defined in the Applet class:  public String getParameter(String parametername);

8 程式範例 :  DisplayMessage.html + DisplayMessage.java + MessagePanel.java ( 課本 P.537 LISTING15.8)

9 程式範例 :  Ball.java + BallControl.java + BounceBallApp.html

10 程式練習 :


Download ppt "Applet and Multimedia 2011.04.29. Outline Developing Applets Applet Life-Cycle Method Passing Strings to Applets [Sample code] DisplayLabel.html."

Similar presentations


Ads by Google