Skip to main content

I need help with some icons on my labels

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
Justinweq
Offline
Joined: 2013-12-02

Hello i need some help with some strange glitches when setting my images i have to some labels icon.
Here is my code for rolling the dice which plays a short animation of the dice rolling

</p>
<p> private void rollTheDice()<br />
    {<br />
        Dice dice1 = new Dice();<br />
        Dice dice2 = new Dice();<br />
        short roll1 = 0,roll2 = 0;<br />
        for(int i = 0;i <= 30;i++)<br />
        {<br />
        roll1 = dice1.roll();<br />
        roll2 = dice2.roll();</p>
<p>        switch(roll1)<br />
        {<br />
            case 1:<br />
                die1jLabel.setIcon(side1);<br />
           case 2:<br />
                die1jLabel.setIcon(side2);<br />
           case 3:<br />
                die1jLabel.setIcon(side3);<br />
           case 4:<br />
                die1jLabel.setIcon(side4);<br />
           case 5:<br />
                die1jLabel.setIcon(side5);<br />
           case 6:<br />
                die1jLabel.setIcon(side6);<br />
        }<br />
         switch(roll2)<br />
        {<br />
            case 1:<br />
                die2jLabel.setIcon(side1);<br />
           case 2:<br />
                die2jLabel.setIcon(side2);<br />
           case 3:<br />
                die2jLabel.setIcon(side3);<br />
           case 4:<br />
                die2jLabel.setIcon(side4);<br />
           case 5:<br />
                die2jLabel.setIcon(side5);<br />
           case 6:<br />
                die2jLabel.setIcon(side6);<br />
        }<br />
            try {<br />
                Thread.sleep(33+i);<br />
            } catch (InterruptedException ex) {<br />
                Logger.getLogger(Main_GUI.class.getName()).log(Level.SEVERE, null, ex);<br />
            }<br />
        }</p>
<p>    }<br />

Here is my icons

<br />
 Icon side1  = new  ImageIcon("src/Images/die1.png"),<br />
            side2 = new ImageIcon("src/Images/die2.png"),<br />
            side3 = new ImageIcon("src/Images/die3.png"),<br />
            side4 = new ImageIcon("src/Images/die4.png"),<br />
            side5 = new ImageIcon("src/Images/die5.png"),<br />
            side6 = new ImageIcon("src/Images/die6.png");<br />

As far as I can tell this code should be working, but for some reason when I click on the roll button which roll's the dice the dice disappear completely(I am making a craps simulation by the way).
If anyone knows what is going on please say so.

Thanks, JustinWeq