/***************************************************************
 * Source: @(#)$Id$
 * Scope:  AWT Fixes width labels
 *
 *  12/16/1999  GVT  First Implementation
 ***************************************************************/

package gvt.awt;

import java.awt.*;

/**
 * AWT implementation of fixed size labels
 *
 * @author   Giuseppe Vitillaro
 * @version  $Id$
 */
public class FixedLabel extends Label {
    private int width;
    
    /**
     * Construct an empty label of width char
     */
    public FixedLabel ( int width ) {
	this.width = width;
    }

    /**
     * override root class getPreferredSize
     */
    public Dimension getPreferredSize ( ) {
	Dimension d = super.getPreferredSize();
	Font font = getFont();
	if ( font != null )
	    d.width = width*getFontMetrics ( font ).charWidth('m');
	return d;
    }
}
