Please explain.Quote:
that still doesn't work,
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.
Printable View
Please explain.Quote:
that still doesn't work,
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.
I have already set the button to have an ImageIcon though, I just need to know how I can tell if it has an image or not,
say I have two buttons I click on one, and I want to know if the left of that button has an image?
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.Quote:
how I can tell if it has an image or not,
I have looked at the API, and I can only find checkImage(), but not sure how to use it in this context :/ ?
Thanks for all your help again
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.
I have tried:
Code :System.out.println("There is an image!"); }
But I get a nullPointerExceptionError?
What variable is null? Where does the code assign a non-null value to the variable?Quote:
I get a nullPointerExceptionError
See posts #49 and 43. Make sure the code is not using a variable that is local to a method.
it assigns a null value to the 'leftbtn', I just can't seem to get it :/
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 many variables named: button are defined in the code?
Which one has values assigned to it?
Which one NEVER has values assigned to it and will contain null entries?
THANK YOU SOOOOOOOO MUCH!
You have made my day!!!
Glad you found it. I don't know why IDEs don't give warnings when variable definitions shadow other definitions.