Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Sultan Ali

Greenhorn
+ Follow
since Jul 21, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sultan Ali

Hi everyone, I'm working on a checkers game, i have problem with piece movements, currently i have few classes which i will upload, but my main problem is that i can't move my piece to a new location within the board, I have it so that when a piece is clicked it position is checked, and the mouse listens to a new square that user clicks, if the square doesn't have a piece on it then a Boolean is set to true.
I really need an advice help of how i could go about moving the pieces to a new location within the board.

8 years ago
What i think you need to do is create a method with the information and then called that method in your main method using a while loop, this should solve you problem.... if you dont understand what i mean i will give you an example
e.g



dont forget to code your tags
9 years ago
Try working of this.
9 years ago
Many thanks for the kind responds,
I got it working but unsure if my method is correct but atleast is working, i simply defined the x and y positions of each J component i needed fillovals in my piece class
e.g




i then called it in my main class as follow



This seems to work at the moment but if you guys have any better way then please..
9 years ago
My Main problem is how to store a list of JComponent into arraylist i tried to add it but it wouldnt work, Does anyone have a Solution??
9 years ago
Use the Dispose function for that frame only when you click the button call this dispose in your actionperformed
9 years ago
Hi Everyone, Am currently working on a Checkers game (English draughts) to upgrade my java skills, But am having Slight difficulties placing the pieces into the Board and I am unsure of how i could go about it, i know i would have to store all the pieces into an array then loop through the array and add it to the Board But since the pieces are all JComponent (Filloval) i dont know how i could store Jcomponents into an array, Is it possible to add a number of fillovals into an Arraylist?. i tried this but it doesn't work, I would appreciate any Advice of how i could go about it?

cheers





9 years ago