Problem

(Screen Saver Using theJava 2D API) Modify your solution to Exercise to use classes and dr...

(Screen Saver Using theJava 2D API) Modify your solution to Exercise to use classes and drawing capabilities of the Java 2D API. Draw shapes like rectangles and ellipses, with randomly generated gradients. Use class GradientPaint to generate the gradient.

Exercise

(Screen Saver with Shapes) Modify your solution to Exercise such that it uses random-number generation to choose different shapes to display. Use methods of class Graphics.

Exercise

(Screen Saver for a Random Number of Lines) Modify your solution to Exercise to enable the user to enter the number of random lines that should be drawn before the application clears itself and starts drawing lines again. Use a JTextFiel d to obtain the value. The user should be able to type a new number into the JTextField at any time during the program's execution. Use an inner class to perform event handling for the JTextFiel d.

Exercise

(Screen Saver Using Timer) Package javax.swing contains a class called Timer that is capable of calling method actionPerformed of interface ActionListener at a fixed time interval (specified in milliseconds). Modify your solution to Exercise to remove the call to repaint from method pai ntComponent. Declare your class to implement ActionListener. (The actionPerformed method should simply call repaint.) Declare an instance variable of type Ti mer called ti mer in your class. In the constructor for your class, write the following statements:

timer = new Timer(1000, this);

timer.startO;

This creates an instance of class Timer that will call this object's actionPerformed method every 1000 milliseconds (i.e., every second).

Exercise

(Screen Saver) Write an application that simulates a screen saver. The application should randomly draw lines using method drawLine of class Graphics. After drawing 100 lines, the application should clear itself and start drawing lines again. To allow the program to draw continuously, place a call to repaint as the last line in method paintComponent. Do you notice any problems with this on your system?

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 13
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT