I receive the following error when attempting to compile this code:
ChessGameDemo.java:120: cannot resolve symbol
symbol : method setLocationRelativeTo (<null>)
location: class javax.swing.JFrame
frame.setLocationRelativeTo( null );
^
1 error
Thank you very much for this useful code.
The correction is that you should change this code:
/////////////////////
if (row == 0)
square.setBackground( i % 2 == 0 ? Color.blue : Color.white );
else
square.setBackground( i % 2 == 0 ? Color.white : Color.blue );
}
////////////////////
To be:
///////////////////
if (row == 0) // For odd square
square.setBackground( i % 2 == 0 ? Color.white : Color.gray );
else
square.setBackground( i % 2 == 0 ? Color.gray : Color.white );
}
/////////////////
Because the chess board must start with white upper left corner and end with white lower right corner.
Thanksalonon April 1, 2011 at 3:03 PM
thank you it's very simple and easy
Thanks a LotMarcelo Garca November 24, 2011 at 5:36 PM
Your code help me a lot! I made a chess - text mode, and now i need to convert for swing. I will use your board at swing. Tks a lot!
awesomexyz March 1, 2013 at 10:24 PM
aweosme code! thanks a ton!! :*
ErrorAlex July 16, 2012 at 5:35 AM
I receive the following error when attempting to compile this code: ChessGameDemo.java:120: cannot resolve symbol symbol : method setLocationRelativeTo (<null>) location: class javax.swing.JFrame frame.setLocationRelativeTo( null ); ^ 1 error
Very Use Full to fressersS.VinodhKumar September 1, 2012 at 7:59 PM
Thanks to every one to giving such information.
Thanks and correctionTamawy November 17, 2012 at 1:33 AM
Thank you very much for this useful code. The correction is that you should change this code: ///////////////////// if (row == 0) square.setBackground( i % 2 == 0 ? Color.blue : Color.white ); else square.setBackground( i % 2 == 0 ? Color.white : Color.blue ); } //////////////////// To be: /////////////////// if (row == 0) // For odd square square.setBackground( i % 2 == 0 ? Color.white : Color.gray ); else square.setBackground( i % 2 == 0 ? Color.gray : Color.white ); } ///////////////// Because the chess board must start with white upper left corner and end with white lower right corner.
Post your Comment