Glad you found it. I don't know why IDEs don't give warnings when variable definitions shadow other definitions.
Type: Posts; User: Norm
Glad you found it. I don't know why IDEs don't give warnings when variable definitions shadow other definitions.
That means that the button array has a null value. Why does the button array have a null value?
See posts #49 and 43. Make sure the code is not using a variable that is local to a method.
How...
What variable is null? Where does the code assign a non-null value to the variable?
See posts #49 and 43. Make sure the code is not using a variable that is local to a method.
Your code uses the setIcon() method to set the image.
Look at the getIcon() method for getting the image that was set with the setIcon() method.
Call the method that will return the image if it has one. Read the API doc for the JButton class and see what method returns the current icon/image that the object is using.
Please explain.
Why use client properties when the class has a method you can call directly to determine if it has an image: see the icon get and set methods for the class.
Get a reference to the JButton object and call its methods to determine its state.
This statement sets leftbtn to the button object:
JButton leftbtn = buttons[button1rowLeft][button1column];...
Please explain. What do you mean by "source"?
Where is the variable: button defined?
Every variable in a program must be defined before it can be used. Some variable definitions:
Object obj;
int anInt;
double aDbl;
You are not using that definition of button which is local to the constructor. Look for the definition of button that you are using.
The error message could mean that the array only has one dimension not two.
Check that the definition for the array you are trying to use has 2 dimensions.
The error message could mean that the array only has one dimension not two.
Check that the definition for the array you are trying to use has 2 dimensions.
Where on the line with the error does the IDE put the indicator flag that points to the location of the error on the line? See the ^ in post #35. It's beneath where there error is: var
Where does...
Please post the FULL text of the error message that shows where the error happened and the source line with the error.
Here is a sample:
TestSorts.java:138: cannot find symbol
symbol :...
Please post the full text of the error message and the source code where the error happens.
button[button1rowLeft][button1column];
refers to a JButton object, not to an array of JButtons.
Try this:
JButton leftbtn = button[button1rowLeft][button1column];
I posted an example in post#27
Compute the indexes and use them to index into the button array.
What is the index into the button array for the clicked button?
Say it was 4,5. Then the button on the same row (4) and two columns to the right would be at column 7
Then the array element:...
This array needs to be a class variable so it can be used to get a reference to any of the buttons:
JButton[][] button = new JButton[8][8];
Given the row,col of a button, index into that array to...
Given a reference to a JButton object (get that from the array using its r,c location), you can call its methods and determine its state.
Look at the API doc for the JButton class to see what...
When you get the row,col location of the clicked button, you can use that in the array to get to any other button in the array by changing the row and/or col values.
Ok, you're welcome. Good luck.
see you tomorrow.
the value that was written to the button with the putClientProperty() method. The buttons location in a row and column variable.
See post#11
There is a reference to the event button. The button...
I thought that you had written the code that you posted in post #8. That code saves values with the button component's client properties. Those values are saved in a sort of map. Use the client...