Say that the Graphics object grph has a drawing area of width=200 and
height=150.
Fill in the blanks so that a line is drawn from the lower left corner to the
upper right corner of the area.
Answer:
grph.drawLine( 0, 149, 199, 0 )
Since the height is 150, and the numbering of pixels starts at zero, the Y coordinate of the lower left corner is 149.
End of the Chapter
You may wish to browse through the following. Click on a subject that interests you to go to where it was discussed.
- Why applets have no main method.
-
Extending
the built-in class
JApplet. - The setBackground() method.
- Graphics objects and their methods.
- Compiling and running applets.
- Including an applet on a Web page.
- HTML
- List of HTML tags.
- The paint() method.
- The drawOval() method.
- The drawRect() method
- Pen colors.