package gui;

import java.awt.*;
import javax.swing.*;

/**
 * A component that contains text.  This component is slightly
 * more versatile than a JLabel because it wraps at word
 * boundaries.
 *
 * @version 1.0
 * @author  Prof. David Bernstein
 */
public class WrappingLabel extends JTextArea
{

    /**
     * Default constructor
     */
    public WrappingLabel()
    {
	this("");
    }



    /**
     * Explicit Value Constructor
     *
     * @param text   The text on the label
     */
    public WrappingLabel(String text)
    {
	super(text);


	// Set the wrapping behavior
	setLineWrap(true);
	setWrapStyleWord(true);

	// Make this TextComponent behave like a Lavel
	setEditable(false);
	setHighlighter(null);
    }




    /**
     * Reloads the pluggable UI. 
     */
    public void updateUI()
    {
	super.updateUI();

	// Change the border (to the one used by Label objects)
	LookAndFeel.installBorder(this, "Label.border");

	// Change the background color, foreground color,
	// and font (to those used by Label objects)
	LookAndFeel.installColorsAndFont(this,
					"Label.background",
					"Label.foreground",
					"Label.font"
					);
    }
}
