ArrayList problem with images
I have this code:
Code:
public static ArrayList<ImageIcon> imRay = new ArrayList<ImageIcon>();
ImageIcon one = new ImageIcon("0.png");
ImageIcon two = new ImageIcon("1.png");
public Test() {
initComponents();
this.setLocationRelativeTo(null);
imRay.add(one);
imRay.add(two);
}
Then, later on, under a button:
Code:
int i = 0;
i = jComboBox1.getSelectedIndex();
jLabel3.setIcon(imRay.get(i));
However, whilst it doesn't throw an error (unless I select a value in the jComboBox that is higher than currently allowed), it doesn't change the icon in jlabel3.
Where am I going wrong?