?
Solved

Color Question

Posted on 2005-04-24
3
Medium Priority
?
271 Views
Last Modified: 2010-03-31
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
Comment
Question by:rajah_mohammed
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
suprapto45 earned 1200 total points
ID: 13855867
Hi,

Please have a look at this URL.

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

Regards
Dave
0
 

Author Comment

by:rajah_mohammed
ID: 13855890
Thanks got it from you link :
if((int)(i+j)/2==(int)(i+j+1)/2) {
}
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13855921
Glad I could help.

Regards
Dave
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question