In the action listener for the button, the getSource() method will return a reference to the button that was clicked so you can get its values.
I don't understand this part. There is only one...
Type: Posts; User: Norm
In the action listener for the button, the getSource() method will return a reference to the button that was clicked so you can get its values.
I don't understand this part. There is only one...
Do you want to have the button contain the row and col values?
A couple of ways to do that.
1)Extent the JButton class with your class that can contain the row and col values that you can get from...
Can you explain what you want to do with the button that is clicked?
Do you want to disable the button that was clicked on so it can't send any more events?
If you cast the object returned by getSource() to a button, you can call the button's methods.
Does it work when compiled and executed? Does it return the right results?
It looks better.
I added some comments after first post.
Do you have a question?
One problem I see is the use of an assignment operator (=) instead of an equality test operator(==)
Testing a boolean variable for equal to true is redundant. Its value...
Define which way is forward and then test if the move is in that direction. The near pieces move away from you, the far pieces move towards you.
Can you explain where you are having a problem with the code? Ask a specific question about it.
Have a variable like a boolean that says if this is the first move or not.
Initialize it as true and set it false when the first move is made.
Can you determine if its the first move and allow 2 squares if so?