public class GLabel extends GObject
GLabel
class is a graphical object whose appearance consists
of a text string.Modifier and Type | Field and Description |
---|---|
static java.awt.Font |
DEFAULT_FONT
The default font used to display strings.
|
Constructor and Description |
---|
GLabel(java.lang.String str)
Creates a new
GLabel object initialized to contain the specified string. |
GLabel(java.lang.String str,
double x,
double y)
Creates a new
GLabel object with its baseline origin at the
specified position. |
Modifier and Type | Method and Description |
---|---|
double |
getAscent()
Returns the distance this string extends above the baseline.
|
GRectangle |
getBounds()
Returns a
GRectangle that specifies the bounding box for the string. |
double |
getDescent()
Returns the distance this string descends below the baseline.
|
java.awt.Font |
getFont()
Returns the font in which the
GLabel is displayed. |
java.awt.FontMetrics |
getFontMetrics()
Returns a
FontMetrics object describing the dimensions of this string. |
double |
getHeight()
Returns the height of this string, as it appears on the display.
|
java.lang.String |
getLabel()
Returns the string displayed by this object.
|
double |
getWidth()
Returns the width of this string, as it appears on the display.
|
void |
paint(java.awt.Graphics g)
Implements the
paint operation for this graphical object. |
java.lang.String |
paramString()
Returns a string indicating the parameters of this object.
|
void |
setFont(java.awt.Font font)
Changes the font used to display the
GLabel . |
void |
setFont(java.lang.String str)
Changes the font used to display the
GLabel as specified by
the string str , which is interpreted in the style of
Font.decode . |
void |
setLabel(java.lang.String str)
Changes the string stored within the
GLabel object, so that
a new text string appears on the display. |
addActionListener, addMouseListener, addMouseMotionListener, contains, contains, fireActionEvent, fireActionEvent, getColor, getLocation, getParent, getSize, getX, getY, isVisible, move, movePolar, pause, removeActionListener, removeMouseListener, removeMouseMotionListener, sendBackward, sendForward, sendToBack, sendToFront, setColor, setLocation, setLocation, setParent, setVisible, toString
public static final java.awt.Font DEFAULT_FONT
setFont
method.public GLabel(java.lang.String str)
GLabel
object initialized to contain the specified string.str
- The initial contents of the GLabel
public GLabel(java.lang.String str, double x, double y)
GLabel
object with its baseline origin at the
specified position.str
- The initial contents of the GLabel
x
- The x-coordinate of the label originy
- The y-coordinate of the baseline for the labelpublic void setFont(java.awt.Font font)
GLabel
. This call will
usually change the size of the displayed object and will therefore affect
the result of calls to getSize
and getBounds
.font
- A Font
object indicating the new fontpublic void setFont(java.lang.String str)
GLabel
as specified by
the string str
, which is interpreted in the style of
Font.decode
. The usual format of the font string is
familycode>-stylecode>-size where both style and size are optional. If any of these parts are specified as an asterisk, the existing value is retained.
str
- A String
specifying the new fontpublic java.awt.Font getFont()
GLabel
is displayed.public void setLabel(java.lang.String str)
GLabel
object, so that
a new text string appears on the display.str
- The new string to displaypublic java.lang.String getLabel()
public void paint(java.awt.Graphics g)
paint
operation for this graphical object. This method
is not called directly by clients.public double getWidth()
public double getHeight()
public double getAscent()
public double getDescent()
public java.awt.FontMetrics getFontMetrics()
FontMetrics
object describing the dimensions of this string.FontMetrics
object describing the dimensions of this stringpublic GRectangle getBounds()
GRectangle
that specifies the bounding box for the string.public java.lang.String paramString()