I have an image that has to make up a 8x8 grid, so it is a background for the board.
I have been told it is possible to do this using ImageIcon and a JLabel, which I tried and it doesn't seem to work.
- It doesn't allow me to add components to it (piece, which is also a JLabel).
- Also when the program is running and I click on a square- it disappears, which is not ideal as it is supposed to be the background.
Here is the code:
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
square=new JLabel();
square.setIcon(icon);
chessBoard.add( square );
}
}
The full code: http://pastebin.com/YdavUmGz
Am I doing something horribly wrong with this background image?
Any help would be appreciated, thanks in advance.