// FieldButton.java Copyright (c) 2004 brising.com import java.awt.Color; import java.awt.event.ActionEvent; import java.beans.PropertyChangeSupport; /** I am a button out in the middle of the game's button matrix. I am either black (untested), blue (tested and occupied), or yellow (tested and unoccupied). */ public class FieldButton extends GameButton { // STATIC VARIABLES /////////////////////////////////////////////////////////// static public final String gksUpdateFound = "updateFound"; // INSTANCE VARIABLES ///////////////////////////////////////////////////////// boolean hyOccupied; // PUBLIC INSTANCE METHODS //////////////////////////////////////////////////// /** See if I am occupied. Turn blue if I am, or yellow if I am not. */ public void actionPerformed ( ActionEvent aoActionEvent ) { if (this.hasBackgroundDefault()) { if (isOccupied()) { setBackground(Color.blue); gkoPropertyChangeSupport .firePropertyChange(gksUpdateFound,null,null); } else { setBackground(Color.yellow); changeScore(); } } } /** My default background color is black. */ public Color getBackgroundDefault ( ) { return Color.black; } /** How many points do I subtract from the game's score if I am unoccupied? */ public int getScore ( ) { return 5; } /** Am I occupied? */ public boolean isOccupied ( ) { return hyOccupied; } /** Do Photons propagate through me? */ public boolean isPropagating ( ) { return !this.isOccupied(); } public void reset ( ) { super.reset(); setOccupied(false); } public void setOccupied ( boolean ay ) { hyOccupied = ay; } public void terminate ( ) { // do nothing } }