
package jp.riken.brain.ni.samuraigraph.base;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.AbstractButton;

/**
 *
 */
public class SGButtonGroup implements ActionListener
{

	private ArrayList mButtonList = new ArrayList();

	public SGButtonGroup()
	{
		super();
	}


	public void add( AbstractButton btn )
	{
		this.mButtonList.add(btn);
		btn.addActionListener( this );
	}


	public void remove( AbstractButton btn )
	{
		this.mButtonList.remove(btn);
		btn.removeActionListener( this );
	}


	public void actionPerformed( ActionEvent e )
	{
		AbstractButton btn = (AbstractButton)e.getSource();
		ArrayList list = this.mButtonList;
		for( int ii=0; ii<list.size(); ii++ )
		{
			AbstractButton b = (AbstractButton)list.get(ii);
			if( btn.equals(b) == false )
			{
				b.setSelected(false);
			}
		}
	}


}

