Basic HTML version of Foils prepared Sept 21 1998

Foil 4 Methods for drawing in the Graphics Class

From Java Tutorial 98- 3: Graphics and the Abstract Windowing Toolkit NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

Simple Graphics Examples for Foil 4
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)
drawString (String text, x, y)
drawLine (x1, y1, x2, y2)
drawRect (x, y, width, height), fillRect (...),
drawOval (...), fillOval (...),
drawRoundRect (x, y, width, height, arcWidth, arcHeight)
  • for a rectangle with rounded corners!,
draw3DRect (x, y, width, height, Boolean b)
  • (to get shadow effect as in buttons - if b is true, it's raised),
drawArc (x, y, width, height, startAngle, arcAngle), fillArc(..),
drawPolygon(int xPoints[], int yPoints[], n);



© 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 Sat Nov 28 1998