Lab5 - CS 241 Lab 5 Lab 5: Simple Graphics CS 241 PURPOSE...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 241 Lab 5 1 | P a g e Lab 5: Simple Graphics CS 241 PURPOSE This lab will introduce you to Java’s framework for working with simple graphics, as well as the concept of an animation loop and dialog boxes for I/O. OVERVIEW You are provided with two starter files for this lab: BallTest.java and BallPanel.java. BallTest extends JFrame and provides the window containing the components for the animation. BallTest also contains the animation loop that controls when the graphics in the animation are updated and redrawn. The animation loop is infinite – it halts only when the window is closed. BallPanel ex- tends JPanel and provides a graphical panel containing two bouncing balls. The position, height and width, and color of the balls are tracked in BallPanel, as well as rise and run values for each ball that determine how far (and in what direction) the balls will move each time their positions are updated. Initially, the balls bounce off the edges of the panel but do not collide with each oth- er. BallPanel also contains the methods called by the animation loop to update and redraw the panel. These methods consist of a move method, which updates the position of the balls in the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Lab5 - CS 241 Lab 5 Lab 5: Simple Graphics CS 241 PURPOSE...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online