This is the MSEgui chessboard example, written by Martin Schreiber, continued by Fred van Stappen and Roland Chastain.
Now the program knows legal chess moves and game state (check, checkmate, stalemate).