// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SoftButton.java

import java.awt.*;
import java.awt.event.*;

public class SoftButton extends Canvas
    implements MouseListener
{

    SoftButton()
    {
        actionCommand = "BUTTONCLICK";
        bkColor = Color.black;
        fgColor = Color.white;
        raised = true;
        setBackground(bkColor);
        setForeground(fgColor);
    }

    SoftButton(String s)
    {
        actionCommand = "BUTTONCLICK";
        bkColor = Color.black;
        fgColor = Color.white;
        raised = true;
        label = s;
        setBackground(bkColor);
        setForeground(fgColor);
    }

    SoftButton(ActionListener actionlistener)
    {
        actionCommand = "BUTTONCLICK";
        bkColor = Color.black;
        fgColor = Color.white;
        raised = true;
        al = actionlistener;
        setBackground(bkColor);
        setForeground(fgColor);
    }

    SoftButton(String s, ActionListener actionlistener)
    {
        actionCommand = "BUTTONCLICK";
        bkColor = Color.black;
        fgColor = Color.white;
        raised = true;
        label = s;
        al = actionlistener;
        setBackground(bkColor);
        setForeground(fgColor);
    }

    String getActionCommand()
    {
        return new String(actionCommand);
    }

    void setActionCommand(String s)
    {
        actionCommand = s;
    }

    void setLabel(String s)
    {
        label = s;
    }

    String getLabel()
    {
        return label;
    }

    void addActionListener(ActionListener actionlistener)
    {
        al = AWTEventMulticaster.add(al, actionlistener);
    }

    void removeActionListener(ActionListener actionlistener)
    {
        al = AWTEventMulticaster.remove(al, actionlistener);
    }

    public void paint(Graphics g1)
    {
        g = g1;
        FontMetrics fontmetrics = g1.getFontMetrics();
        char ac[] = new char[label.length()];
        label.getChars(0, label.length() - 1, ac, 0);
        int i = (width - fontmetrics.charsWidth(ac, 0, label.length())) / 2;
        int j = (height - (fontmetrics.getHeight() + fontmetrics.getLeading())) / 2;
        g1.setColor(bkColor);
        g1.draw3DRect(0, 0, width, height, raised);
        g1.setColor(fgColor);
        g1.drawString(label, i, j);
    }

    private void lookClickedOn()
    {
        raised = false;
        try
        {
            Thread.sleep(300L);
        }
        catch(Exception _ex) { }
        raised = true;
    }

    public void mouseReleased(MouseEvent mouseevent)
    {
        lookClickedOn();
        al.actionPerformed(new ActionEvent(this, 1001, actionCommand));
    }

    public void mouseClicked(MouseEvent mouseevent)
    {
    }

    public void mouseEntered(MouseEvent mouseevent)
    {
    }

    public void mouseExited(MouseEvent mouseevent)
    {
    }

    public void mousePressed(MouseEvent mouseevent)
    {
    }

    String actionCommand;
    private ActionListener al;
    private String label;
    Graphics g;
    Color bkColor;
    Color fgColor;
    int height;
    int width;
    boolean raised;
    static final int BUTTON_EVENT = 1001;
}
