June 2005
Beginner to intermediate
336 pages
6h 29m
English
Applications that draw using sprites often do their drawing in a new execution stream—that is, a new thread. The reason for this is because while the new thread draws the sprites and moves them around, the main thread in the application can be doing other things—such as, in this application, closing the window when the user clicks the close button.
The drawing and graphics work that goes on behind the scenes will take place in this new thread. To handle a new thread, you make sure that an application implements the Runnable interface:
import java.awt.*;
import java.awt.event.*;
public class Aquarium extends Frame implements Runnable
{
.
.
.
}
The Runnable interface has only one method, run, which is called when you start a ...
Read now
Unlock full access