Please explain.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.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Please explain.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.
If you don't understand my answer, don't ignore it, ask a question.
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.how I can tell if it has an image or not,
If you don't understand my answer, don't ignore it, ask a question.
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.
If you don't understand my answer, don't ignore it, ask a question.
I have tried:
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?I get a nullPointerExceptionError
See posts #49 and 43. Make sure the code is not using a variable that is local to a method.
If you don't understand my answer, don't ignore it, ask a question.
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?
If you don't understand my answer, don't ignore it, ask a question.
sim18 (December 4th, 2012)
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.
If you don't understand my answer, don't ignore it, ask a question.