So, this code is giving me some errors, any idea?
private void pintarMobs()
{
JButton boton = null;
Component[] botones = pnCastillo.getComponents();
for (Component c: botones){
boton = (JButton) c;
int ac = Integer.parseInt(boton.getActionCommand());
int a = 0;
Random r = new Random();
String foto = null;
if( ac != 0){
if (ac == 6)
foto = "/img/ghostking.png";
else if (ac == 1)
foto = "/img/busters.png";
else
a = r.nextInt(8-1) + 1;
if(a==1)
foto = "/img/ghost1.png";
else if(a==2)
foto = "/img/ghost2.png";
else if(a==3)
foto = "/img/ghost3.png";
else if(a==4)
foto = "/img/ghost4.png";
else if(a==5)
foto = "/img/ghost5.png";
else if(a==6)
foto = "/img/ghost6.png";
else if(a==7)
foto = "/img/ghost7.png";
else if(a==8)
foto = "/img/ghost8.png";
}
boton.setIcon(new ImageIcon(getClass().getResource(foto)));
}
}