Here is the thing- my Main method only calls InitGui. Inside the whole class (basically the whole file, i have the InitGui method and a few public static gui objects. One of the objects is actuall an array
public static JButton Keys[] = null;
And I have a method called placeKeys that gets the location for each JButton “Keys” and places it on the panel. The whole code works when I do not use this method, basically instead of for i=0 to whatever, I want just call placeKey(arguments here…) instead of
for each jButton to be placed like this
for i=0 to whatever
Keys[i] = new JButton(jBStringArray[i]);
Keys[i].setLocation(2 + i*kSize,2+row*50);
Keys[i].setSize(50, kSize);
keyboardPane.add(Keys[i]);
I have the method written down but it reports a pointer error at the placeKeys when it tries to access the Keys[] , meaning the first line of the method
Hope you understood me
Before your for loop (either when you declare it, or, if you rely on the null check, just before the for loop) you need to create the array with
Keys = new JButton[whatever+1];. Oh and please start your variable names with a lowercase letter – it’s the universally-accepted thing to do.