CPS 1 - Spring, 2000 - Ramm 2/28/00 #18

Chapt 4: Top-Down Programming, Subroutines, and a Database Application

Chapt 5: Graphics, Classes, and Objects

  • A Touch of Graphics (By Example)

  • Basic Stuff
    • Canvas class
    • Graphics class
    • pixels
    • Coordinates

  • Graphics Methods
    • void drawLine(int x1, int y1, int x2, int y2)
    • void drawRect(int x, int y, int width, int height)
    • void drawOval(int x, int y, int width, int height)
    • fill verson
    • void setColor(Color c)

  • Example: Fixed Location
    GDemo.java, GDemo.html

  • Example: Changing Location
    GDemo2.java, GDemo2.html

  • Example: Using Arrays
    GDemo3.java, GDemo3.html

  • Other Methods
    • void drawSTring(String s, int x , int y)
    • Setting colors
      Color blah; blah = newColor(100, 100, 100);