Download presentation
Presentation is loading. Please wait.
Published byEmerald Hunt Modified over 9 years ago
1
Chapter 8 Frameworks
2
Frameworks 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
3
Example of Frameworks Applets (1) Applet: Java program that runs in a web browser Programmer forms subclass of Applet or JApplet overwrites Init start stop destroy paint
4
Example of Frameworks Applets (2) init Called exactly once, when a class that extends the Applet class. Purpose: Initialize data structures and add user interface elements start 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.
5
Example of Frameworks Applets (3) 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.
6
Example of Frameworks Applets (4) paint Called when the applet window needs repainting. Purpose: Redraw the window contents to reflect the current state of the applet data structures.
7
Example of Frameworks Applets (5)
8
Example of Frameworks Applets (6) Sample Source Code: Shows scrolling banner HTML page contains applet tag and parameters
9
Example of Frameworks Applets (7) ch8/applet/BannerApplet.java ch8/applet/BannerApplet.java ch8/applet/BannerApplet.html init method reads parameters start/stop start and stop timer paint paints the applet surface
10
Example of Frameworks Applets (8)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.