Class TextPanel

public class TextPanel
extends Panel
TextPanel is a more versatile version of the TextArea class. It will allow certain words in the panel to be highlighted where in a TextArea object all words have to be of the same color.
 

Variables

o panelSize
    private Dimension panelSize

        The size of the TextPanel object.

o cursor
    private Point cursor

        The location of where the next letter will appear.

o text
    private Vector text

        A list of TextString objects. It stores the contents of the text that is to be displayed in the panel.

o f
    private Font f

        The font used in the panel.

o fm
    private FontMetrics fm

        A tool that is used to get information about a particular font. Information such as size.

o lineSpacing
    private int lineSpacing

        The space between each line.

o scrollBar
    private ScrollPane scrollBar

        The scroll bar for the TextPanel.
 

Constructors

o TextPanel
    public TextPanel()

        Creates an empty TextPanel object.
 

Methods

o getPreferredSize
    public Dimension getPreferredSize()

        Returns the size of the TextPanel.

o append
    public void append(String string, Color color)

        Creates a TextString object out of the method parameters and append the text at the location pointed by the cursor.

o appendNewLine
    public void appendNewLine(String string, Color color)

        The same as the append method except the cursor is moved to beginning of the next line before appending the text.

o paint
    public void paint(Graphics g)

        Draw the text.



Send all bug reports and comments to tchou@elux3.cs.umass.edu