September 2005
Beginner
576 pages
13h 6m
English
This hour's workshop is an animation that definitely couldn't be replicated with an animated GIF file or any other non-programming alternative. You'll write a program that bounces a tennis ball around the screen in lazy arcs, bouncing off the sides of the panel that contains the animation. Though a few laws of physics will be broken along the way, you'll learn one way to move an image file around the screen.
Create a new file in your word processor called BouncePanel.java, and enter the text of Listing 24.3 into it. Save and compile the file when you're done.
1: import java.awt.*; 2: import javax.swing.*; 3: import java.util.*; 4: 5: public class BouncePanel extends ... |
Read now
Unlock full access