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.
|