/* Copyright Andy C. Deck 1999 All rights reserved. */    
import java.awt.*;

public class label extends Canvas {

String str = "";
String old = "";
boolean down = false;

    public label(String s){
	    super();
	    setBackground(Color.lightGray);
	    str = s;
	    old = s;
    }

    public void update(Graphics g){
	   paint(g);
	}
    public void paint(Graphics g){
	    FontMetrics fm=getFontMetrics(getFont());
        int wid = fm.stringWidth(str);
		Dimension d = size();
        g.clearRect(1,1,d.width-2,d.height-2);
	    g.setColor(Color.darkGray);
        g.drawString(str,(d.width-wid)/2,2+(2*d.height)/3);
		g.setColor(Color.black);
        g.drawRect(0,0,d.width-1,d.height-1);
    }

    public void setMouseDown(boolean b){
	    down = b;
    }
    public boolean mouseDown(){
	  return down; 
    }

    public void setText(String s){
	  if(s != null) str = s;
	  repaint();
    }
	
    public String getText(){
	  return str;
    }

    public void saveText(String s){
	  old = s;
    }

    public void revertText(){
	  str = old;
	  repaint();
    }
}
	
