drawString
statement
to the paint
method, defined in a subclass of the JComponent
class, by instantiating the following pattern:
graphics context.drawString(a string, x, y);
FontMetrics
class using the
graphics context, and then examine that instance's instance variables by
instantiating the following patterns:
FontMetrics fontMetrics = graphics context.getFontMetrics(); ... fontMetrics.getHeight() <-- Fetch height ... fontMetrics.stringWidth(a string); <-- Fetch width
graphics context.setFont(new Font(name, Font.style, size));
The name is a string, such as "Helvetica"
.
The style is the name of a Font
class variable, such as BOLD
.
The size is an integer specifying size, such as 12
, for a 12-point font.