Java Reference
In-Depth Information
center point. Compute the distance between the current location
of the mouse pointer and the center point to determine the cur-
rent radius of the circle.
PP 8.23 Design and implement an application that serves as a mouse
odometer, continually displaying how far, in pixels, the mouse
has moved (while it is over the program window). Display the
current odometer value using a label. Hint : Use the mouse move-
ment event to determine the current position, and compare it to
the last position of the mouse. Use the distance formula to see
how far the mouse has traveled, and add that to a running total
distance.
PP 8.24 Design and implement a program whose background changes
color depending on where the mouse pointer is located. If the
mouse pointer is on the left half of the program window, display
red; if it is on the right half, display green.
PP 8.25 Design and implement a class that represents a spaceship, which
can be drawn (side view) in any particular location. Create a
program that displays the spaceship so that it follows the move-
ment of the mouse. When the mouse button is pressed down,
have a laser beam shoot out of the front of the spaceship (one
continuous beam, not a moving projectile) until the mouse but-
ton is released.
PP 8.26 Design and implement a program that helps a hospital analyze
the flow of patients through the emergency room. A text input
file contains integers that represent the number of patients that
entered the emergency room during each hour of each day for
four weeks. Read the information and store it in a three dimen-
sional array. Then analyze it to compare the total number of
patients per week, per day, and per hour. Display the results of
the analysis.
PP 8.27 Modify the Direction program from this chapter so that the
image is not allowed to move out of the visible area of the panel.
Ignore any key event that would cause that to happen.
PP 8.28 Modify the Direction program from this chapter so that, in
addition to responding to the arrow keys, it also responds to
four other keys that move the image in diagonal directions.
When the 't' key is pressed, move the image up and to the left.
Likewise, use 'u' to move up and right, 'g' to move down and
left, and 'j' to move down and right. Do not move the image if
it has reached a window boundary.
Search WWH ::




Custom Search