CSC 112
Ileana Streinu

7. Paint Sun

  1. Modify the applet so that it paints a square, instead of a disk (sun) on the applet window, on a white background.

  2. Hint: the method for drawing a filled rectangle is fillRect, and you can learn about other such objects worth drawing on the canvas from the on-line documentation.

  3. Choose some other interesting shape from the list of methods that can be applied to a Graphics object, and draw it on the canvas.

  4. Extend this applet with the functionality of some of the previous applets (buttons and text). More precisely: add a button. When the button is clicked, the "sun" changes colors (from a collection of, say, 3 colors), and some text describing what happened (e.g. "Red sun") is drawn on the screen.