|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object acm.graphics.GObject acm.graphics.GLabel
public class GLabel
The GLabel
class is a graphical object whose appearance
consists of a text string.
Field Summary | |
---|---|
static Font |
DEFAULT_FONT
The default font used to display strings. |
Constructor Summary | |
---|---|
GLabel(String str)
Creates a new GLabel object initialized to contain the specified string. |
|
GLabel(String str,
double x,
double y)
Creates a new GLabel object with its baseline origin at the
specified position. |
Method Summary | |
---|---|
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. |
Font |
getFont()
Returns the font in which the GLabel is displayed. |
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. |
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(Graphics g)
Implements the paint operation for this graphical object. |
String |
paramString()
Returns a string indicating the parameters of this object. |
void |
setFont(Font font)
Changes the font used to display the GLabel . |
void |
setFont(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(String str)
Changes the string stored within the GLabel object, so that
a new text string appears on the display. |
Methods inherited from class acm.graphics.GObject |
---|
addActionListener, addMouseListener, addMouseMotionListener, areMouseListenersEnabled, colorName, contains, contains, fireActionEvent, fireActionEvent, fireMouseListeners, getColor, getComponent, getLocation, getObjectColor, getParent, getSize, getX, getY, isVisible, move, movePolar, paintObject, pause, removeActionListener, removeMouseListener, removeMouseMotionListener, repaint, sendBackward, sendForward, sendToBack, sendToFront, setColor, setLocation, setLocation, setParent, setVisible, start, start, toString, updateEnabledList |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Font DEFAULT_FONT
setFont
method.
Constructor Detail |
---|
public GLabel(String str)
GLabel
object initialized to contain the specified string.
str
- The initial contents of the GLabel
public GLabel(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 labelMethod Detail |
---|
public double getAscent()
public GRectangle getBounds()
GRectangle
that specifies the bounding box for the string.
getBounds
in class GObject
public double getDescent()
public Font getFont()
GLabel
is displayed.
public FontMetrics getFontMetrics()
FontMetrics
object describing the dimensions of this string.
FontMetrics
object describing the dimensions of this stringpublic double getHeight()
getHeight
in class GObject
public String getLabel()
public double getWidth()
getWidth
in class GObject
public void paint(Graphics g)
paint
operation for this graphical object. This method
is not called directly by clients.
paint
in class GObject
g
- The graphics context into which the painting is donepublic String paramString()
paramString
in class GObject
public void setFont(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(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
family-style-size
where both style and size are optional. If any of these
parts are specified as an asterisk, the existing value is retained.
- Parameters:
str
- A String
specifying the new font
public void setLabel(String str)
GLabel
object, so that
a new text string appears on the display.
str
- The new string to display
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |