title: Assigning image using random assigns the same image to all JButtons
body: <p>Made a simple Dice throwing test from my code, in an attempt to find why the same image is displayed for every JButton. I have a feeling that the values are not being properly read by the program and so it assigns the same image to all the JButtons.</p>
  
  <p>Test Class</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  
  public class Test extends JFrame {
  
      JButton[] pic = new JButton[5];
      JPanel panel = new JPanel();
      JButton throwDice = new JButton("Throw");
      ImageIcon img;
  
      Die[] dieH = new Die[5];
      Dice dice = new Dice();
  
      Test(String title) {
          super(title);
          setSize(400, 400);
          setLayout(new BorderLayout());
          add(panel, BorderLayout.CENTER);
          components();
          throwHandle();
      }
  
      public static void main(String[] args) {
          Test test = new Test("Test");
          test.setVisible(true);
      }
  
      public void components() {
          for (int i = 0; i &lt; 5; i++) {
              pic[i] = new JButton("");
              pic[i].setPreferredSize(new Dimension(50, 50));
              panel.add(pic[i]);
          }
          panel.add(throwDice);
      }
  
      public void throwHandle() {
          throwDice.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  dieH = dice.roll();
  
                  for (int i = 0; i &lt; 5; i++) {
                      pic[i].setIcon(dieH[i].getDieImage());
                      System.out.println(dieH[i].getValue());
                  }
              }
          });
      }
  }
  </code></pre>
  
  <p>Die Class</p>
  
  <pre><code>import javax.swing.*;
  
  public class Die {
  
      int faceValue;
      ImageIcon img;
  
      public ImageIcon getDieImage() {
          return img;
      }
  
      public void setImage() {
          for (int i = 0; i &lt; 7; i++) {
          img = new ImageIcon("./src/images/" + i + ".png");
          }
      }
  
      public void setValue(int v) {
          this.faceValue = v;
          setImage();
      }
  
      public int getValue() {
          return faceValue;
      }
  }
  </code></pre>
  
  <p>Dice Class</p>
  
  <pre><code>import java.util.Random;
  
  public class Dice {
  
      Die[] diceArray = new Die[6];
  
      int min = 1, max = 6;
  
      public Dice() {
          for (int i = 0; i &lt; diceArray.length; i++) {
          diceArray[i] = new Die();
          diceArray[i].setValue(i + 1);
          }
       }
  
      public Die[] roll() {
          Random rm = new Random();
          Die[] roll = new Die[5];
  
          for (int i = 0; i &lt; 5; i++) {
              int newRandom = rm.nextInt((max - min) + 1);
              roll[i] = diceArray[newRandom];
              System.out.println(roll[i].getValue());
          }
  
          return roll;
      }
  
  }
  </code></pre>