{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Week11_Assignment - paint and call repaint then fall...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Assignment for Chapter 15 Write an applet that simulates a screen saver. The applet should randomly draw lines using method drawLine of class Graphics . After drawing 100 lines, the applet 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 the method paint . Some issues for you to consider: 1. The update method automatically clears the screen before calling paint . You will need to override this method so that it simply calls paint . 2. When you want to erase the screen (i.e., the line counter gets to 100), consider calling super.update . 3. You must not have a loop in paint that prints the 100 lines. You must draw a single line in
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: paint , and call repaint , then fall through the bottom of the paint routine. 4. You’ll need to pause between each line that’s drawn. There are several ways of doing this. You might use the index to read about a version of repaint that lets you pass a pause time, or you could also look up sleep . Extra Credit: Draw the individual lines with random colors, changing the background color to a new color for each set of 100 lines. Update: The repaint method with the millisecond pause is currently not working properly with JBuilder. Currently, the best way to pause uses the following code: try { Thread.sleep( the amount of milliseconds put here ); } catch (InterruptedException e) { }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online