You are facing scope issues, leftDie
scope is restricted to if block only so, move the ImageIcon leftDie ==
out of your if
statements. Change this code:
if (valLeft==1)
{
ImageIcon leftDie = new ImageIcon("Die1.png");
}
To like this:
ImageIcon leftDie = null;
if (valLeft==1)
{
leftDie = new ImageIcon("Die1.png");
}
This should work.