salvin francis wrote:Welcome To code ranch Christopher. Thank you for sharing your code with us.
I havent tried out your program yet, but I have looked at your git code at
https://github.com/gitchrisadams/StartingOutJavaNotes/commit/2f2b43ea0a555ebe675a994953a0f5cfdb210c8a
A couple of points from my end :
1. You code benefit from Lists/Arrays instead of having 9 references to each button
2. A lot of code is repeated for Button1Listener ... Button9Listener, can you reduce it to one listener only?
3. You could benefit using loops in your determineWinner method (also note that the code for xWinner, oWinner is exactly the same and is repeated).
Hi Salvin, Thanks for the feedback.
Points 1 and 2:
There may well be a way to do this with ArrayLists but being new to Swing/Java Gui I did not see a way to do this with my current abilities. I'm pretty familiar with Arrays and Arraylists but that didn't seem to fit when I was going through this.
As for the 9 references to each button. The way the game works is that each button needs to respond to a click event so I don't see away around not having a Listener for each button. Not saying, there isn't a way to do this. Just wasn't apparent to me when working this out.
Point 3:
You're right about xWinner and oWinner being the same and I could re-work.
Could you explain how the determineWinner could benefit from loops.
Point 4: Panels
You are definitely right about this. I am learning about GUI layout and am only familiar with a few layouts and how to lay things out in panels and I'm not using any kind of Gui layout tool.
I originally posted this message in Beginning Java forum and noticed it was moved to game development so just a disclosure, I'm not posing this as the next million dollar app

I just
started into the Java Swing and Gui stuff this week.
Salvin, thanks so much for your thorough response and taking the time to look at the code. Much appreciated.
Chris