Week11_Assignment

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. Youll need to pause between each line thats 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

This note was uploaded on 10/12/2009 for the course CS 120 taught by Professor Robertdependahl during the Fall '09 term at Santa Barbara City.

Ask a homework question - tutors are online