CS 101 Lecture 2 - Graphics, Event Handling

Class Examples:

  1. Design a class that first draws the words "up" and "down" on the screen, with the word "up" in red and "down" in gray. When the mouse is depressed, reverse the colors.

    Click on UpDown to show the example.

  2. Design a class that first draws the phrase "The mouse is up" on the screen. When the mouse is depressed, the phrase is replaced by "The mouse is down". Similarly when the mouse is released, "The mouse is up" is shown again.

    Click on SimpleUpDown to show the example.

  3. Design a class that draws lines from where the mouse is pressed to the current location of the mouse.

    Click on Spirograph to show the example.

  4. Design a class that creates a scribble. That is, it draws line segments joined end to end as the mouse moves.

    Click on Scribble to show the example.

  5. Design a class that draws crosshairs over the current mouse location.

    Click on CrossHairs to show the example.