java.awt.Graphics

java.awt.Graphics is an abstract class that defines a veritable kitchen sink of graphical operations. Its 47 public methods can be used for rendering images and text, drawing and filling shapes, clipping graphical operations, and much more.

Nearly all applets (and applications) that use the AWT manipulate a Graphics for at least one graphical service. For example, even simple Hello World applets are quick to use a Graphics to display their clever verbiage:

public class HelloWorld extends Applet {
   public void paint(Graphics g) {
      g.drawString("Hello Graphic Java World", 75, 100);
   }
}

In addition to performing graphical operations within a component, each Graphics also keeps track of the following graphical properties:

  • The color ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.