Class ShadowLabel
java.lang.Object
|
+----ShadowLabel
- public class ShadowLabel
- extends Object
- implements DrawingObj
This is another example implementation of the DrawingObj
interface. This particular class enables a test string to be displayed
on the drawing panel with a shadowing effect.
For example, the following lines initializes an instance of this class
and display a text string "Hello" on the drawing panel with blue text color
and gray shadow at position (100, 100):
ShadowLabel helloLabel = new ShadowLabel("Hello");
drawingPanel.addDrawingObj(helloLabel);
helloLabel.move(100, 100);
helloLabel.setColor(Color.blue);
drawingPanel.redraw();
This object can be removed from the drawing panel by using the
removeObj
method from DrawingPanel
.
- See Also:
- removeObj
-
ShadowLabel(String)
- Construct a new shadow label with the initial text string as
specified by the parameter.
-
draw(Graphics)
- Draw the text string with a gray label.
-
getText()
- Get the text string for this label object.
-
getX()
- Get the left most positionn of the shadow label.
-
getY()
- Get the bottom most positionn of the shadow label.
-
move(int, int)
- Move this shadow label to the new position with its bottom left
corner specified by the paramters.
-
setColor(Color)
- Set the text color of the drawing object.
-
setText(String)
- Set the text string for this drawing object.
ShadowLabel
public ShadowLabel(String str)
- Construct a new shadow label with the initial text string as
specified by the parameter.
- Parameters:
- str - The initial text string for this shadow label.
setColor
public void setColor(Color col)
- Set the text color of the drawing object.
- Parameters:
- col - The new text color of the object.
setText
public void setText(String str)
- Set the text string for this drawing object.
- Parameters:
- str - The new text string for label object.
getText
public String getText()
- Get the text string for this label object.
- Returns:
- the text string for this label object.
getX
public int getX()
- Get the left most positionn of the shadow label.
- Returns:
- the x-coordinate of the bottom left corner of the shadow label.
getY
public int getY()
- Get the bottom most positionn of the shadow label.
- Returns:
- the y-coordinate of the bottom left corner of the shadow label.
move
public void move(int x,
int y)
- Move this shadow label to the new position with its bottom left
corner specified by the paramters.
- Parameters:
- x - The left most position of the shadow label.
- y - The bottom most position of the shadow label.
draw
public void draw(Graphics g)
- Draw the text string with a gray label. This method is normally
called from the drawing panel paint method.