300 likes | 521 Views
Outline. Java Applet [ p.2 in Java-17-Applet.pdf ] Execution method [ p.11, 12 in Java-17-Applet.pdf ] Applet class Applet life cycle Graphics method AWT GUI with Listener. 1. Java Applet. Framework:. XXX.html. XXX.Java. XXX.Class. XXX.Class. 1. Java Applet (Example 1).
E N D
Outline Java Applet [p.2 in Java-17-Applet.pdf] Execution method [p.11, 12 in Java-17-Applet.pdf] Applet class Applet life cycle Graphics method AWT GUI with Listener
1. Java Applet Framework: XXX.html XXX.Java XXX.Class XXX.Class
1. Java Applet (Example 1) Align text left No constructor here [p.5 in Java-17-Applet.pdf] No main [p.9], setVisible [p.9], setTitle [p.9], setSize [p.10], setDefaultCloseOperation [p.10] methods as well Align top
1. Java Applet (Example 1) [p.26 in Java-17-Applet.pdf]
3. Java Applet (Example 2) Example:
3. Java Applet (Example 2) Example:
3. Java Applet (Example 2) Example:
2. Execution Method The 1st method: Using the appletviewer FirstAppletDemo.html Description - The appletviewer command allows you to run applets outside of the context of a World-Wide Web browser. http://download.oracle.com/javase/1.3/docs/tooldocs/win32/appletviewer.html
2. Execution Method The 2nd method: Html
3. Applet Class Main Methods (Life cycle): init() – called exactly once in an applet's life, when the applet is first loaded start() – alled at least once in an applet's life, when the applet is started or restarted stop() – called at least once in an applet's life, when the browser leaves the page in which the applet is embedded destroy() – called exactly once in an applet's life, just before the browser unloads the applet http://www.cafeaulait.org/course/week5/28.html
4. Applet Life Cycle paint() http://www.cafeaulait.org/course/week5/28.html
4. Applet Life Cycle Example:
4. Applet Life Cycle Example:
4. Applet Life Cycle Example:
5. Graphics (0, 0) (250, 0) 90 輸出文字 60 (60, 90) (0, 250) (250, 250)
5. Graphics Example:
5. Graphics Example:
5. Graphics Example:
6. AWT GUI AWT (Abstract Windowing Toolkit): Label Button Checkbox Choice TextField List Scrollbar …
6. AWT GUI Example:
6. AWT GUI Example:
6. AWT GUI Example:
7. AWT GUI Example:
7. Listener Example:
7. AWT GUI Example:
7. AWT GUI Example:
Weekly Sentence • No gains without pains