Exercise 2: Drawing Other Stuff

Home/Java - Tutorial/Java - Applet/Exercise 2: Drawing Other Stuff
Exercise 2: Drawing Other Stuff 2015-12-04T17:36:49+00:00

[ Home | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 ]
The source code:

(Download the below file: DrawingStuff.java)

The resulting applet looks like this:

For documentation on the Graphics class and the parameters that are passed to functions such as drawRect(), fillOval(), etc., go here.

Please note that some of the member functions in Graphics, such as fillRect(), interpret the width and height parameters as measured between pixel edges; hence the resulting figure will truly be width pixels wide and height pixels high. However, other functions, such as drawRect(), assume dimensions are measured between pixel centres; hence the resulting figure will actually be width+1 by height+1 pixels.