ChessView
March 13th, 2009

ChessView
A swing chess board component. Includes an example applet (see below) to demonstrate it’s use.
Example Applet
Download the source and have a look at the applet for an example of how to use the component. Simple. Just initialize a board, get its model and update it when it changes.
ChessBoard board = new ChessBoard(); // initializes to the start position. Container contentPane = getContentPane(); contentPane.add(board);
Updating is Simple
// 8x8 char array that gives the pieces on each square
char[][] raw_board =
{ { 'R', 'N', 'B', 'Q', 'K', 'B', 'N', 'R' }, {
'P', 'P', 'P', 'P', ' ', 'P', 'P', 'P' }, {
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, {
' ', ' ', ' ', ' ', 'P', ' ', ' ', ' ' }, {
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, {
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, {
'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p' }, {
'r', 'n', 'b', 'q', 'k', 'b', 'n', 'r' }};
ChessBoardModel model = board.getModel();
model.updateBoard(raw_board);
The Applet in Action
From Alekhine-Capablance, New York 1927. Alekhine played 22. fxg6.