public void changeState(){
  linked=!linked;
  link=linked ? linkedImIc.getImage() : unlinkedImIc.getImage();
  repaint();
}

public void changeState ( ) { linked = ! linked ; link = linked ? linkedImIc . getImage ( ) : unlinkedImIc . getImage ( ) ; repaint ( ) ; }
changes the lock icon ' s image to whatever it currently is not . also changes the locked flag accordingly .
