21 Days:
Wk1
. Wk1Ref
. Applts
. Swing
. Grph
. D13-14
. D15-21
. D22-28
cc12: Miscl . SQL . EJB . Vocab . (NotesHelp) . J2EE . Web misl: 21 Days(src) . Dictionary(foldoc) . Unicode . Tables . Print . html misl: F.Allimant . Swing (J.H.University) |
Java Home
Refererences and Links.
Notes.
DAY 13: Threads and Animation. (pg.329-358: 30 pages)
- History of Animation on the web: See pg 329. . Java applets 1st was method. Java still best for complex animation. - To do anmimation in Java, use the Abstract Windowing Toolkit, Swing and the Thread class. - Animation can be moving figures, or dynamically updated apps and applets. Main aspects of animation are: 1) Animation works by overriding the the paint() method in applets, and the paintComponent() method in apps. 2) Animation can be in its own thread. 3) Using bitmaps like GIF, JPG, and PNG files. ===Creating Animation (pg.330) ===PAINTING AND REPAINTING: - Previously when used paint() and paintComponent() methods, they always displayed the same thing. You can reference variables within these methods that can be set before calling them. Call repaint() to call these methods. Calls to repaint() are put on a stack and handled when possible. If there are too many, some of the calls can get skipped. - Usually, one call to paint will handle one frame of animation. - For better results, always call repaint() instead of calling paint methods directly. ===ANIMATING A COMPONENT: (p.331) - To draw on a component, override its paintComponent(Graphics) method. (paint(Graphics) for applets). - If outputing outside a component's boarders, only what is inside the component is drawn. ===Controlling Animation Through Threads. - A class that uses threads must implement the Runnable interface. (p.336) - run() is the one required method for this interface. run() is called when you call a threads start() method. ===Stopping a Thread. This is a little more complicated. - Several techniques are possible to stop a thread. (p.339-340) - (finished to p.343.middle) - (finished to p.345.end)
DAY 14: JavaSound. (pg.359-377: 19 pages)
************************************************************************************* B19 - Teach Yourself Java 2 in 21 Days. 2nd ed. Lemay and Cadenhead. © 2001. *************************************************************************************