public class TextShape extends ShapeImpl implements Shape
Constructor and Description |
---|
TextShape(java.lang.String txt,
int x,
int y)
Create a new text shape, in black using the default font
|
TextShape(java.lang.String txt,
int x,
int y,
java.awt.Color c)
Create a new text shape, using the default font
|
TextShape(java.lang.String txt,
int x,
int y,
java.awt.Color c,
java.awt.Font font)
Create a new text shape
|
TextShape(java.lang.String txt,
int x,
int y,
java.awt.Font font)
Create a new text shape, in black
|
Modifier and Type | Method and Description |
---|---|
void |
paint(java.awt.Graphics g)
Paint this shape onto the given graphics context.
|
void |
setFont(java.awt.Font newFont)
Change the font.
|
void |
setText(java.lang.String newText)
Change the text.
|
java.lang.String |
toString()
Answer the printed representation of this shape.
|
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, moveTo, recordWindow, removeFromWindow, rotateAround, setColor
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, moveTo, recordWindow, removeFromWindow, rotateAround, setColor
public TextShape(java.lang.String txt, int x, int y)
txt
- the text to displayx
- the X coordinate of the upper-left corner of the text shapey
- the Y coordinate of the upper-left corner of the text shapepublic TextShape(java.lang.String txt, int x, int y, java.awt.Font font)
txt
- the text to displayx
- the X coordinate of the upper-left corner of the text shapey
- the Y coordinate of the upper-left corner of the text shapefont
- the font of the text shapepublic TextShape(java.lang.String txt, int x, int y, java.awt.Color c)
txt
- the text to displayx
- the X coordinate of the upper-left corner of the text shapey
- the Y coordinate of the upper-left corner of the text shapec
- the color of the textpublic TextShape(java.lang.String txt, int x, int y, java.awt.Color c, java.awt.Font font)
txt
- the text to displayx
- the X coordinate of the upper-left corner of the text shapey
- the Y coordinate of the upper-left corner of the text shapec
- the color of the textfont
- the font of the text shapepublic void paint(java.awt.Graphics g)
Shape
public void setText(java.lang.String newText)
newText
- the new text of the text shapepublic void setFont(java.awt.Font newFont)
newFont
- the new font of the text shape