+ All Categories
Home > Documents > Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

Date post: 21-Jan-2016
Category:
Upload: naomi-hampton
View: 227 times
Download: 0 times
Share this document with a friend
10
Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee
Transcript
Page 1: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

Chapter 8 (Horstmann’s Book)Frameworks

Hwajung Lee

Page 2: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

Framework is a set of cooperating classes and interface types that structures the essential mechanisms of a particular domain. Example: Swing is a GUI framework Framework != design pattern Typical framework uses multiple design

patterns Inversion of control: framework controls

execution flow

Page 3: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

Applet: Java program that runs in a web browser

Programmer forms subclass of Applet or JApplet overwrites ▪ Init▪ start▪ stop▪ destroy▪ paint

Page 4: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

init Called exactly once, when a class that

extends the Applet class. Purpose: Initialize data structures and add

user interface elementsstart

Called when the applet is first loaded and every time the user restore the browser window containing the applet.

Purpose: Start or restart thread that perform animation or other tasks.

Page 5: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

stop Called when the user hides the browser

window containing the applet and when the browser terminates.

Purpose: Stop thread from updating the applet so computing resources are conserved when the applet is not being viewed.

destroy Called when the browser terminates. Purpose: Relinquish any resources that

were acquired during init or other processing.

Page 6: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

paint Called when the applet window needs

repainting. Purpose: Redraw the window contents to

reflect the current state of the applet data structures.

Page 7: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.
Page 8: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

Sample Source Code: Shows scrolling banner

HTML page contains applet tag and parameters

<applet code="BannerApplet.class" width="300" height="100"> <param name="message" value="Hello, World!"/> <param name="fontname" value="Serif"/> <param name="fontsize" value="64"/> <param name="delay" value="10"/> </applet>

Page 9: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

ch8/applet/BannerApplet.java ch8/applet/BannerApplet.html

init method reads parameters start/stop start and stop timer paint paints the applet surface

Page 10: Chapter 8 (Horstmann’s Book) Frameworks Hwajung Lee.

Recommended