04-16-2008, 05:45 PM
I will say upfront that this is for a class I am taking. We initially had to make a chess program and have it use the command line. Now we know how to do GUIs and we must make it a GUI chess program. My difficulty lies with click events. I have my chess board lied out with JToggleButtons so you can click the piece you want to move, then where you want to move to. I am trying to figure out how I should setup the click events. This program must place checkers too, so I have a few abstract classes in the mix as well. I have a class that sets up the game board and is also an abstract class. Well I need to setup my click events when I do the board, so I initially made a separate class that when the click event was added I could add the x and y board coordinate to it, so it could use it. I then had planned to have the click event (ActionListener) call my chess game class to do the move things, then I thought about it and realized that would not work. I have been trying to come up with something, but I am having trouble. What I really need is a way to send commands to an instance of a class from an unrelated class. If someone could help me with a strategy that does that, or something I would be most grateful.