import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;


/**
 * TODO Put here a description of what this class does.
 * 
 * @author Annmarie Stanley. Created Mar 28, 2008.
 */
public class TogglerButton extends JButton implements ActionListener {

	private Color original, other;
	
	public TogglerButton() {
			super();
			double ran = Math.random();
			if (ran < 0.5) {this.setBackground(Color.BLACK); this.original = Color.black; this.other = Color.white;}
			else {this.setBackground(Color.WHITE); this.original = Color.white; this.other = Color.black;}
		}

	public void actionPerformed(ActionEvent e) {
		this.setBackground((this.getBackground() == this.original) ? this.other
				: this.original);
		
//		boolean win = true;
//		for (int j = 0; j < this.arr.length; j++) {
//			Color orig = this.arr[0].getBackground();
//			Color test = this.arr[j].getBackground();
//			if (!(orig.equals(test))) {win = false;}
//			System.out.println("testing if win: " + win);
//		}
//		if (win) {
//			this.setTitle("Congrats, you win!");
//		}
		
		
		
		
		
		
		TogglerFrame.testWin(this);
	}





}
