hamsam.api
Class TextComponent

java.lang.Object
  |
  +--hamsam.api.TextComponent
All Implemented Interfaces:
MessageComponent

public class TextComponent
extends java.lang.Object
implements MessageComponent

A text component of a message.

A text component contains a sequence of characters that represent a message. This sequence, together with the font and color information, determines what to display to the user.

This class defines various methods to set and retrieve the sequence of characters, as well as the font and color information.


Constructor Summary
TextComponent()
          Construct a new text component that represents an empty character sequence.
TextComponent(java.lang.String str)
          Construct a new text component and initialize it with the given character sequence.
TextComponent(java.lang.String str, java.awt.Color color)
          Construct a new text component and initialize it with a given character sequence and color information.
TextComponent(java.lang.String str, java.awt.Font font)
          Construct a new text component and initialize it with a given character sequence and font information.
TextComponent(java.lang.String str, java.awt.Font font, java.awt.Color color)
          Construct a new text component and initialize it with a given character sequence, font, and color information.
 
Method Summary
 void append(char[] str)
          Appends the sequence of characters to this text component.
 void append(java.lang.String str)
          Appends the string to this text component.
 java.awt.Color getColor()
          Returns the color that is used with this text component.
 java.awt.Font getFont()
          Returns the font that is used with this text component.
 char[] getSequence()
          Returns the sequence of characters corresponding to this text component.
 void setColor(java.awt.Color color)
          Specify the color to be used with this text component.
 void setFont(java.awt.Font font)
          Specify the font to be used with this text component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextComponent

public TextComponent()
Construct a new text component that represents an empty character sequence. This constructor is equivalent to TextComponent(null, null, null).


TextComponent

public TextComponent(java.lang.String str)
Construct a new text component and initialize it with the given character sequence. This constructor is equivalent to TextComponent(str, null, null).

Parameters:
str - sequence of characters representing this text component.

TextComponent

public TextComponent(java.lang.String str,
                     java.awt.Color color)
Construct a new text component and initialize it with a given character sequence and color information. This constructor is equivalent to TextComponent(str, null, color).

Parameters:
str - sequence of characters representing this text component.
color - the color of the text represented by this component.

TextComponent

public TextComponent(java.lang.String str,
                     java.awt.Font font)
Construct a new text component and initialize it with a given character sequence and font information. This constructor is equivalent to TextComponent(str, font, null).

Parameters:
str - sequence of characters representing this text component.
font - the font of the text represented by this component.

TextComponent

public TextComponent(java.lang.String str,
                     java.awt.Font font,
                     java.awt.Color color)
Construct a new text component and initialize it with a given character sequence, font, and color information.

Parameters:
str - sequence of characters representing this text component.
font - the font of the text represented by this component.
color - the color of the text represented by this component.
Method Detail

append

public void append(java.lang.String str)
Appends the string to this text component.

Parameters:
str - the string to be appended.

append

public void append(char[] str)
Appends the sequence of characters to this text component.

Parameters:
str - the characters to be appended.

getSequence

public char[] getSequence()
Returns the sequence of characters corresponding to this text component.

Returns:
the sequence of characters of this component.

setFont

public void setFont(java.awt.Font font)
Specify the font to be used with this text component.

Parameters:
font - the font to be used.

getFont

public java.awt.Font getFont()
Returns the font that is used with this text component.

Returns:
the font used.

setColor

public void setColor(java.awt.Color color)
Specify the color to be used with this text component.

Parameters:
color - the color to be used.

getColor

public java.awt.Color getColor()
Returns the color that is used with this text component.

Returns:
the color used.