Suppose the student wishes to simply draw lines to create a stunningly
interesting visual display. Java provides the drawLine method for this
purpose. Here's how to use it:
g.drawLine(30, 50, 130, 50);This example will draw a horizontal line starting at (30,50) and ending at (130,150). That is, the starting point is 30 units to the right of the left edge of the applet area and 50 units down from the top of the applet area. The end point is 130 units to the right of the left edge of the applet area and 50 units down from the top of the applet area.
This example will create a vertical line:
g.drawLine(50,30,50,130);Here's another example that renders a diagonal line:
|EXAMPLE: This applet is an approximation of what the student will be expected to create. No code will be offered since the student will need to experiment with the use of the drawLine method to successfully complete this activity.|
Basically, the student will create a tic tac toe grid. The only trick here is figuring out how to place the four lines required to create the grid in appropriate locations.