• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

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.
0
rajah_mohammed
Asked:
rajah_mohammed
  • 2
1 Solution
 
suprapto45Commented:
Hi,

Please have a look at this URL.

http://www.ux1.eiu.edu/~cfprc/javbk/wjpr.html

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

Regards
Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now