public void flip(){
  if (greenlight) {
    img=null;
    repaint();
    img=stop.getImage();
  }
 else {
    img=null;
    repaint();
    img=go.getImage();
  }
  greenlight=!greenlight;
  firePropertyChange("State",!greenlight,greenlight);
}

public void flip ( ) { if ( greenlight ) { img = null ; repaint ( ) ; img = stop . getImage ( ) ; } else { img = null ; repaint ( ) ; img = go . getImage ( ) ; } greenlight = ! greenlight ; firePropertyChange ( "State" , ! greenlight , greenlight ) ; }
quick method which flips the state of the stoplight to green if the current state is red and red if the current state is green . again the image is always coupled to the greenlight boolean .
