Link to home
Start Free TrialLog in
Avatar of rajah_mohammed
rajah_mohammed

asked on

Color Question

Hi;

I'm trying to create a chess game and I'm trying to implement the chessboard here's what I got :

            for (int i=1; i<=8; i++) {
                  for(int j=1; j<=8; j++ ) {
                        
                        board = new JPanel();
                        board.setBorder(BorderFactory.createEtchedBorder());
                        panel1.add(board);       
                        board.setBackground(Color.white);
                  }
            }

I'm trying to set the colors of each block to white and green just any ordinary chess board. How will I be able to do it in my codes ? thanks.
ASKER CERTIFIED SOLUTION
Avatar of suprapto45
suprapto45
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rajah_mohammed
rajah_mohammed

ASKER

Thanks got it from you link :
if((int)(i+j)/2==(int)(i+j+1)/2) {
}
Glad I could help.

Regards
Dave