Q&A

Q1:Does a threaded animation program have to use Thread.sleep() to pause, or can you omit it to produce the fastest possible animation?
A1: You have to put some kind of pause in place in an animation program, or the program will crash or behave erratically. Without pauses, Java won't be able to keep up with constant repaint() requests and may be unable to respond to mouse-clicks on its interface and other user input. Part of the process of animation design in Java is finding the right display speed that all environments can handle.
Q2:What happens if you draw something, such as an image, to coordinates that aren't within the window?
A2: Methods that draw something to a coordinate will continue to draw it even if none of it is visible within ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.