Graphics Demo 1

GRAPHICS! Kids, we're going to learn how to draw some stuff on the screen in a Java application. Download the following code file and get it to compile.

Files Needed

Study Drills

Answer any questions in comments at the top of GraphicsDemo1.java.

  1. How big is the window that appears? How many pixels wide? How many pixels tall?
  2. In the call to the function g.drawRect(), there are four numbers. What do they mean? Try changing them to figure it out.
  3. What about the call to fillOval()? What do the four numbers mean here?
  4. What are the two numbers in the call to drawString()?
  5. What happens when two objects overlap? Which one is drawn on top?
  6. Add a red, filled-in square somewhere in the lower-right of the canvas.





©2013–2015 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License