Why do I get an error when I try to set the ImageIcon of this JLabel to something. It returns a null pointer exception. Does anyone know the problem?
public class Window extends JFrame{
JPanel panel = new JPanel();
JLabel stick[] = new JLabel[10];
Window(){
super("ThisIsWindow");
setSize(650,550);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
add(panel);
panel.setLayout(null);
stick[5].setIcon(new ImageIcon("stick.gif"));
}
}
The error occurs on the last line of code that sets stick[5] to stick.gif. Can anyone help?