This is the code:
addCube = new JButton("Add Cube");
addCube.addKeyListener(kl);
addCube.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
cubes.add(cube);
}
});
panel.add(addCube);
frame.add(panel, BorderLayout.NORTH);
Where panel is an JPanel and frame is an JFrame. When I execute the code I got the following error message:
Exception in thread "main" java.lang.NullPointerException at cg2k15.CG2K15.main(CG2K15.java:91)
Where line 91 is this: panel.add(addCube);
What am I doing wrong? :/