Basic HTML version of Foils prepared 13 October 97

Foil 4 Methods for drawing in the Graphics Class

From Java Tutorial, July 1, 1996 CSC499(JSU) CPS406/606 -- Fall Semester 97. by Nancy J. McCracken,Geoffrey C. Fox

Simple Graphics Examples for Foil 4
1 Graphics class has methods to construct basic two dimensional images
  • (all parameters are ints unless otherwise indicated)
  • x, y pixel locations refer to the upper left corner of the object to be drawn (except for strings)
2 drawString (String text, x, y)
3 drawLine (x1, y1, x2, y2)
4 drawRect (x, y, width, height), fillRect (...),
5 drawOval (...), fillOval (...),
6 drawRoundRect (x, y, width, height, arcWidth, arcHeight) (for a rectangle with rounded corners!),
7 draw3DRect (x, y, width, height, Boolean b)
8 (to get shadow effect as in buttons - if b is true, it's raised),
9 drawArc (x, y, width, height, startAngle, arcAngle), fillArc(..),
10 drawPolygon(int xPoints[], int yPoints[], n);

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998