floorButton
is not initalised to anything...
public JButton[] floorButton; // I'm null
public ControlPanel(int x) {
//...
for (int i = 0; i < x; i++) { // in
// Still null
floorButton[i].add(new JButton("F" + Integer.toString(i)));
Initalise the array to reflect what you need, also, don't use floorButton[i].add
, you don't want to add the button to (what is currently a null
element) button, you want to assign it to the position of the array...
public ControlPanel(int x) {
//...
floorButton = new JButton[x];
for (int i = 0; i < x; i++) { // in
floorButton[i] = new JButton("F" + Integer.toString(i));
I'm guessing you'll want to do the same with floorIn
...