HELP! * GREY=local LOCAL HTML version of Foils prepared July 10 1996

Foil 143 Some Graphics Methods

From Basic Lectures on Java Language Applets Graphics Networking Trip to China and Icase Tutorial -- July 12-28 and June 10-13 96. by Geoffrey C. Fox * See also color IMAGE

Changing the current state:
  • g.setColor(Color.blue);
  • Font f = new Font("Helvetica", Font.ITALIC, 14);
  • g.setFont(f);
There are many other attributes of text that can be affected by FontMetrics fm = g.getFontMetrics(f);
such as leading, height, and kerning.
Drawing text: g.drawString
Drawing shapes: g.drawLine, g.drawRect, g.drawOval, g.drawArc - and filled shape versions: g.fillRect, etc.
One draws a sequence of text and shapes to define the screen, where the position of the object in the screen is given by pixel coordinates. If one object overlaps another, the latest one drawn covers up the area of overlap.
  • The exception to this is XOR graphics, which may be used to temporarily highlight a particular color. This is an advanced technique as other colors will also be affected.



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 Tue Feb 18 1997