Hello, I'm pretty new to Java and this is my first GUI project, so try to explain like I am 5.
I declare a label normally, then I set an Icon into it like this:
x=rand.nextInt(4)+1;
if (x==1) {
computer.changeInfo("Fox McCloud", 500, 250, 100, 100, 65, 25, 15, 110, 35, 12, 5, 80,"Laser shoot", "That up smash", "Agility", "Laser overload","fox.jpg");
ImageIcon fox = new ImageIcon(computer.getPath());
cimage.setIcon(fox);
} else if (x==2){
computer.changeInfo("Mario", 525,225,100,100, 70,35,22,95, 25,12,5,75,"Ground pound","Bounce Jump","FireBall","Coin UpSmash","mario.jpg");
ImageIcon mario = new ImageIcon(computer.getPath());
cimage.setIcon(mario);
} else if (x==3){
computer.changeInfo("Pikachu", 400,350,100,100, 50,25,15,125, 25,12,5,95,"Thunder","Spark","Quick Attack","Electric Overload","pikachu.jpg");
ImageIcon pikachu = new ImageIcon(computer.getPath());
cimage.setIcon(pikachu);
} else if (x==4){
computer.changeInfo("Veigar", 425,325,100,100, 50,25,15,140, 25,12,5,120,"Dark Matter","Baleful Strike","Little bit of EVIL","Primordial Burst","veigar.jpg");
ImageIcon veigar = new ImageIcon(computer.getPath());
cimage.setIcon(veigar);
} else if (x==5){
computer.changeInfo("King Boo",600,150,100,100,40,30,23,100,20,15,10,60,"Scary Look","Quick Lick","Stealth Attack","Super Scary Move", "kingboo.jpg");
ImageIcon kingboo = new ImageIcon(computer.getPath());
cimage.setIcon(kingboo);
}
(computer is a class I made and computer.getPath() just returns the file path as a String)
Everything is fine and dandy at this point, but when I have an action listner event to restart my game I want to change the icon set to the cimage JLabel, and when I try to do that my there is a nullpointexception error that shows up in the black thing and the line corresponds to one of the lines where I try and set the image icon of JLabel to something else. Somehow the JLabel is becoming null, how can I fix this?