Graphics Demo 3

Here are some more examples of the various functions at your disposal in Java's graphics library. Download the following code and get it to compile.

Files Needed

Study Drills

Answer the questions in comments at the top of GraphicsDemo3.java.

  1. When drawing a line, what do the four numbers represent?
  2. Make a short red line that intersects the long green line.
  3. Make a short red line that is roughly perpendicular to the diagonal "magenta" line.
  4. When drawing a rectangle, where on the rectangle is the starting point you provide? Use the key below.
      the upper-left corner? - o......     ......o - the upper-right corner?
                               .......     .......
                               .......     .......
    
                               .......     .......
                               .......     .......
      the lower-left corner? - o......     ....... - the lower-right corner?
    
    ---------------------------------------------------------------------------------
    
                                     ...o... - the top of the center line?
                                     .......
                                     .......
    
                               .......     .......
    middle of the left side? - o......     ......o - middle of the right side?
                               .......     .......
    
                                     .......
                                     .......
                                     ...o... - the bottom of the center line?
    
    ---------------------------------------------------------------------------------
    
                                     .......
                    or, the absolute ...o... center of the rectangle?
                                     .......
    
  5. When drawing strings, where on the string is the starting point you provide?
  6. When setting a custom font, what happens if you provide a font that doesn't exist?
  7. When setting a custom font, what happens if you provide a font that isn't installed on this machine?
  8. Change the first "Leander Lions" (the white one) to a different font. Change the blue "Leander Lions" to match it.





©2013–2015 Graham Mitchell

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