It changes the current drawing color to blue.
Think of the Graphics object as being like a sheet of paper, some colored pens, and some drawing methods. Use the following to change the color of the paper:
setBackground( Color.something )
Use the following to change to a different color pen:
gr.setColor( Color.something )
Several million colors are possible, but for now, use the pre-defined colors:
Color.red, Color.green, Color.blue, Color.white
static values from
(Look at your local documentation under
Color to find more choices.)
To draw a line on the Graphics object, use:
drawLine(int x1, int y1, int x2, int y2)
This draws a line from (x1, y1) to (x2, y2) in the drawing area using the current pen color. As usual, the point (0,0) is the upper left corner of the drawing area.