import java.awt.event.*; public class EnemyThread extends Thread { public Chess chess = null; public Position enemyPos = null; public EnemyThread(Chess c, Position p) { chess = c; enemyPos = p; } public void run() { Chess.enemyMove = enemyPos.findBestMove(); //computer's reply String result = "moved"; if (Chess.enemyMove == null) { //computer was mated or stalemated result = "checkmated/stalemated"; } chess.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,result)); } public void setPosition(Position p) { enemyPos = p; } public Position getPosition() { return enemyPos; } }