next up previous
Next: Change colors Up: Programming assignment Previous: Create the Hello World

Read about applets

1.
If you have not done so already, read the section of the book about applets. In particular, make sure you understand the drawString and drawOval methods.
2.
Add a second drawString invocation to the program so that it displays another line of text underneath ``Hello, World.'' Make sure it says something witty. Keep in mind that a larger y coordinate means a point lower on the canvas.

3.
Use the drawRect method to draw a rectangle around the two lines of text.

4.
Copy thedrawRect invocation and change it to a drawOval. Run the program again. You should see an oval contained within a rectangle. Hopefully this will make it more clear what the book means by an oval ``inscribed'' in a rectangle. Another way to say the same thing is that the rectangle is the ``bounding box'' of the oval.

Bounding boxes are a common way to specify the size and position of a graphical object, even if that object is not rectangular.



Allen B. Downey
2/11/1998