I'm going through CS106A(Programming Methodology) course from iTunes where in the The Art & Science of Java book associated with the course, there is an exercise called Checkers.
Below is that exercise and as you can see, I've completed the program but not as polished as I hope.
I am using Eclipse and had no Programming Knowledge prior to this course.
How do get rid of the circles or blank checkers from the white squares?
Also how do I make the checkers smaller and centred in each black squares?
Thank you guys.
How are you drawing the board? Are you using the paintComponent method? In which case you would call super.paintComponent(g); as the first line of that method.
Why have you got all that GUI work in the run() method? That ought to be in the constructor of the GUI class, or a method called private void initGUI() called from the constructor.
Don’t know exactly why you are getting that problem, but check those queries and see how far you get.
Jeremy Mazz wrote:I have a question regarding this line
I tried running this code in Eclipse and I ran a println on this statement and received '0' as its output. I know this can't be correct. What is this variable supposed to be calculating. The code above doesn't have any comments. Thanks.
Welcome to the Ranch.
To be honest I don't know. Looking at how it is used I guess it's supposed to be the total board width and the OP was assuming the panel was going to be wider than it was high and so the board would fill the height but would need to be centered on the width. Having said that the calculation doesn't appear to be calculating that so maybe I'm barking up the wrong tree. Without having the rest of the code so I can run it, it's hard to give further advice, sorry.
Maybe someone else here knows the question and can give a better answer.
Jeremy Mazz wrote:Thanks for replying, the rest of the code is two posts up from my original post. I was referring to Goran Dragutinovic code.
Yes, I saw that. That's how I worked out it was probably being used to center the panel along the X axis. But that code is not an SSCCE and so can't be run.