THANK YOU SOOOOOOOO MUCH!
You have made my day!!!
Type: Posts; User: sim18
THANK YOU SOOOOOOOO MUCH!
You have made my day!!!
it assigns a null value to the 'leftbtn', I just can't seem to get it :/
I have tried:
System.out.println("There is an image!");
}
But I get a nullPointerExceptionError?
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
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...
To call the method would that be :
int leftHole = (Integer) leftbtn.getClientProperty("ImageIcon");
Because that still doesn't work, what method would you suggest?
I am basically trying to act like I clicked on that button to easily get the information about it, as this code gives me a null pointer exception
I really hope I am explaining properly :/ I have...
Yes that was my problem thank you :)
public static JButton[][] button; -> I had to change it to [] []
Now
JButton leftbtn = button[button1rowLeft][button1column]; works, but now, my leftbtn...
What do you mean definition of button sorry?
yes it is deffinatly a 2D array because I used :
JButton[][] button = new JButton[8][8]; //Sets new JButtons
I'm really struggling on this, I need to get this done by today and it is this one tiny bit that I need to do to complete my program :(
Sorry about the long reply,
JButton leftbtn = button[button1rowLeft][button1column];
[button1column]
^
it gives me an error on that line specifically [button1column]
I'm not sure what you mean, I am using eclipse and when I try and run the program it just says :
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
The...
"Array required, but javax.swing.JButton found
You are using syntax here that suggests that you are trying to access an array element. The variable you refer to is not an array,though"
That still comes up with the error 'array required. but java.swing.JButton found' ?
When I try and index it into the array :
____________________________________ edit:
and when I do System.out.println on leftbtn its output is: [[Ljavax.swing.JButton;@208ee9c9
Is there a way...
I get that, but I'm not sure how to actually retrieve the source for the button?
When I create the buttons in the array I give each row/col a reference and then i give each row/col +1 & -1 to get...
Thanks for the reply :)
when I do:
JButton[][]
I still get the same 'Source' as I do for the button clicked even though it should be the left button of the button I just clicked?
Hi, i'm really sorry but I have looked a the JButton API doc, I found 'checkHorizontalKey' method, but I am not sure if this is correct as I tried using it.
I can get the buttons row/col...
Hi, thanks for all your help I feel I have done & learnt so much from what you last told me.
I have one last problem. I have done the code that allows me to click one button, click the next...
Just thought I would say thank you so much for your help and letting me know about the client properties. I have read over it lots today and have made so much progress. I haven't got stuck at the...
I will have to have a go tomorrow, thank you very much again
I have gone through the API as you said.
So from:
public void actionPerformed(ActionEvent e) {
JButton src = (JButton) e.getSource();
System.out.println(src);
}...
To be honest I'm not really sure where to start with this, you say that the buttons save their row and columns using client properties, i'm not sure how to get them.