JLabel[] labels=new JLabel[10];
ImageIcon[] image = new ImageIcon[10];
labels[0].setForeground(Color.BLACK);
image[0] = new ImageIcon(this.getClass().getResource("/White.jpg"));
labels[0].setIcon(image[0]);
labels[0].setBounds(12, 124, 31, 18);
frame.getContentPane().add(labels[0]);
I'm trying to create a simple array of JLabels and print an array of ImageIcons on it. But I get this weird error which says it is null:
How can labels[0] be null? Does someone have any idea why may this be happening?
Thank you so much in advance!