title: Java (GUI) adding JButton multiple times?
body: <p>Im learning Java and Im creating a memory type game where you have to find two equal cards.</p>
  
  <p>I have created a Window etc etc but my problem is adding multiple JButtons to it. (my cards are JButtons with icons). I have commented my code where my problem is.</p>
  
  <pre><code>//Get the images.
  private File bildmapp = new File("bildmapp");
  private File[] bilder = bildmapp.listFiles();
  //My own class extending JButton
  Kort[] k = new Kort[bilder.length];
  
  for(int i = 0; i &lt; bilder.length; i++){
          k[i] = new Kort(new ImageIcon(bilder[i].getPath()));
      }
  
  
  
  //Later in my code:
      int sum = rows * columns;
      Kort[] temp = new Kort[sum];
  
              //My function to randomize.
      Verktyg.slumpOrdning(k);
  
              //***********************//
              //Trying to fill a array from K (which contains all cards) so my temp contains SUM cards and SUM/2 pairs
      for(int i = 0; i &lt; sum/2; i++){
          temp[i] = k[i];
          temp[i+sum/2] = k[i];
      }
  
  
              //Problem is that i only get SUM/2 (half of the cards) cards, not the 16 (8 pairs) i would like to  add in this case
              //SYNLIGT = VISIBLE.
      for(int i = 0; i &lt; sum; i++){
          temp[i].setStatus(Kort.Status.SYNLIGT);
          j.add(temp[i]);
      }
  </code></pre>