It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes Checkerboard w/ 64 squares Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Checkerboard w/ 64 squares " Watch "Checkerboard w/ 64 squares " New topic
Author

Checkerboard w/ 64 squares

Ron Ingram
Ranch Hand

Joined: Mar 11, 2011
Posts: 63
Hello forum,

I'm working on an assignment requiring me to create a checkerboard with 64 squares. I've got three classes: A viewer, Checkerboard component, and a checkerboard which constructs the squares.

My attempt so far is to create 2 row methods in the CHeckerboard Class, one that starts a row off with a white square; the second starting with a black square

In the Checkerboard component class, I want to simply call each one four times changing the y coordinate so it lines each row up.

However, this doesn't seem to work. What am I doing wrong?

Viewer Class


Checkerboard Component Class:


Checkerboard Class
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
comment out your current CheckerBoardComponent class and replace with this to see what's happening



Ron Ingram
Ranch Hand

Joined: Mar 11, 2011
Posts: 63
Thank you. I see that the values are all being returned as 0. I hard-coded the values I'm trying to test and still renders the same.. I've included the code now with x replaced with the actual x value I'm looking for. Still prints out as all zeros

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

Your Checkerboard constructor doesn't do anything. Passing it different values won't result in any differences in the Checkerboard objects you create.
Ron Ingram
Ranch Hand

Joined: Mar 11, 2011
Posts: 63
Ahh your right.. I wasn't using the arguments being passed..

I've fixed it and it works.. I've included the solution code for this thread's integrity:

Viewer:


Component Class:



Checkerboard class:
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

You were on the right track, it was the debugging code you posted that made me want to look at the Checkerboard class and its constructor.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Checkerboard w/ 64 squares