title: ArrayList resets in actionPerformed method
body: <p>I am trying to make a Solitaire game, but there is a problem with the arrayList, which is static, in the actionPerformed method. The arrayList is intended to contain cards that have been clicked on, and removes the card at index 0 if more than two are inside of it. Both cards in it are intended to be compared, and the one at the lower index will be moved to the one at the higher index if such a move is legal. The problem, though, is that while the first card clicked on is successfully added to the arrayList, the arrayList suddenly appears as empty when an attempt is made to add a second to it. System.out.println statements were put into the if statements with the remove method calls to see if those were somehow being activated, but none of these statements were called. Do you how the arrayList could be appearing as empty if an add method was called to add a card to it and no remove methods were called (at least according to how they were tested)?</p>
  
  <pre><code>import java.applet.*;
  import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  import java.util.*;
  
  public class Game extends JPanel implements ActionListener {
  
      static ImageIcon Deck1, Temp1, ThreeS,
              Ace1, Ace2, Ace3, Ace4,
              KingH, KingS, KingC, KingD;
  
      Image DeckImage;
      static JButton A1, A2, A3, A4, KS, KH, KD, KC, D1, T1, TS;
      static JButton column1;
      static ArrayList&lt;Card&gt; deck;
      static Card[] cardArray;
      static Card[] temp;
      static int count;
      static JFrame frame;
      static JPanel panel;
      static Game ga;
      static int c = 1;
      static ArrayList&lt;Card&gt; numClicks;
      static ArrayList&lt;Card&gt; col1;
      static ArrayList&lt;Card&gt; col2;
      static ArrayList&lt;Card&gt; col3;
      static ArrayList&lt;Card&gt; col4;
      static ArrayList&lt;Card&gt; col5;
      static ArrayList&lt;Card&gt; col6;
      static ArrayList&lt;Card&gt; col7;
      static Card currentCard;
      static double dragFromX, dragFromY;
  
      public boolean canMove(Card a, Card b) {
          setLayout(null);
  
          if ((a.getValue() &lt; b.getValue()) &amp;&amp; (!a.getColor().equals(b.getColor()))) {
              double x = b.getButton().getLocation().getX();
              double y = b.getButton().getLocation().getY();
              a.getButton().setBounds((int) x, (int) y + 50, 90, 100);
              return true;
          }
  
          return false;
      }
  
      public void actionPerformed(ActionEvent evt) {
          // check which command has been sent
          if (evt.getSource() == D1) {
              count = 1;
          }
  
          numClicks = new ArrayList&lt;Card&gt;();
          // checks to see if a certain card is clicked
          if (evt.getSource() == KD) {
              if (numClicks.size() == 0) {
                  // adds the card to index 0 in numClicks if it's the first click
                  numClicks.add(temp[3]);
  
              } else if (numClicks.size() == 1) {
                  // adds the card to index 1 in numClicks if it's the second click
                  numClicks.add(temp[3]);
                  // checks to see if the card can be moved and moves it if possible
                  canMove(numClicks.get(0),
                          numClicks.get(1));
              } else {
                  // if their is more than three cards, 
                  // then the card in the first index is removed 
                  // and this card is added as the second click 
                  numClicks.remove(0);
  
                  numClicks.add(temp[3]);
                  canMove(numClicks.get(0), numClicks.get(1));
              }
          }
  
          if (evt.getSource() == TS) {
  
              if (numClicks.size() == 0) {
                  numClicks.add(temp[3]);
              } else if (numClicks.size() == 1) {
                  numClicks.add(temp[4]);
                  canMove(numClicks.get(0), numClicks.get(1));
  
              } else {
                  numClicks.remove(0);
                  numClicks.add(temp[4]);
                  canMove(numClicks.get(0), numClicks.get(1));
  
              }
  
              repaint();
          }
      }
  }
  </code></pre>