package jp.co.nri.rid.search;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JColorChooser;


/** 塗色選択ボタンのアクションを監視し、背景色を設定するクラス */
class SPColorListener implements ActionListener {
    /** SCCS ID */
    private static final String SCCSID = "@(#)SPColorListener.java";

    /** RCS ID */
    private static final String RCSID =
	"$Id: SPColorListener.java,v 1.5 2002-10-11 10:42:05+09 nsmr Exp $";

    /** override of ActionListener */
    public void actionPerformed(ActionEvent e) {
	/* イベント発生元が JButton でなければ無視 */
	Object o = e.getSource();
	if (!(o instanceof JButton)) {
	    return;
	}
	JButton button = (JButton)o;

	Color oldColor = button.getBackground();
	String str = SPResourceHash.getString("chooseColor");
	Color newColor = JColorChooser.showDialog(button, str, oldColor);
	if (newColor != null) {
	    button.setBackground(newColor);
	}
    } /* actionPerformed */
} /* class SPColorListener */
