title: Problems losing ArrayList entries
body: <p>I'm currently designing a Pictionary game for my final project in my Java course. It uses a basic Echo Server to echo data from the sender to the receivers. Every GUI gets its own DrawCanvas, but only the artist gets to draw and everyone else watches.</p>
  
  <p>All of the data for the canvas is stored in ArrayLists, one for the lines, one for colors, and one for line thicknesses. When the data is being sent, it is packaged into an Envelope and sent to the server. </p>
  
  <p>The Envelope class is essentially (String key, Object data), so you can ID the envelope using the string and unpackage the data on the other end.</p>
  
  <p>Multiple clients can watch the artist drawing with no problem. The artist canvas continuously sends points (via sendStartPoint() and sendPoint()) to the other clients, which is rebuilt into the canvas on the other end. However, if a client joins after things have been drawn, they need to be updated with all the canvas data, or else they will only see what is added after they joined. To do this, the sendCanvas() and loadCanvas() methods are used.</p>
  
  <p><strong>The problem I have</strong> is that even though sendCanvas() is sending all of the data, the client is only receiving the data for the first line that was drawn.</p>
  
  <p>Other than what is in the DrawCanvas class posted below, this is the only other processing of data -- where the envelope is unpackaged.</p>
  
  <p>I can post more code from other classes if it will help.</p>
  
  <p><strong>Only other processing of the Envelope</strong>
  </p>
  
  <pre class="lang-java prettyprint-override"><code>if (e.getKey().equals("draw")){
      ArrayList&lt;Object&gt; data = (ArrayList&lt;Object&gt;)e.getData();
      ArrayList&lt;ArrayList&lt;Point&gt;&gt; lines = (ArrayList&lt;ArrayList&lt;Point&gt;&gt;)data.get(0);
      ArrayList&lt;Color&gt; colors = (ArrayList&lt;Color&gt;)data.get(1);
      ArrayList&lt;Integer&gt; thickness = (ArrayList&lt;Integer&gt;)data.get(2);
      clientUI.draw(lines, colors, thickness);
  }
  </code></pre>
  
  <p><strong>DrawCanvas</strong>
  </p>
  
  <pre class="lang-java prettyprint-override"><code>private ArrayList&lt;ArrayList&lt;Point&gt;&gt; lines = new ArrayList&lt;ArrayList&lt;Point&gt;&gt;();
  private ArrayList&lt;Color&gt; colorList = new ArrayList&lt;Color&gt;();
  private ArrayList&lt;Integer&gt; thicknessList = new ArrayList&lt;Integer&gt;();
  private Color color = Color.BLACK;
  private int thickness = 3;
  private ChatClient chat;
  MouseAdapter ma;
  
  { // Mouse Listener Block
      ma = new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
              addLine();
              lines.get(lines.size() - 1).add(e.getPoint());
              //sendCanvas();
              sendStartPoint();
              repaint();
          }// end mousePressed
          public void mouseReleased(MouseEvent e) {
              lines.get(lines.size() - 1).add(e.getPoint());
              //sendCanvas();
              sendPoint();
              repaint();
          }// end mouseReleased
          public void mouseDragged(MouseEvent e) {
              lines.get(lines.size() - 1).add(e.getPoint());
              //sendCanvas();
              sendPoint();
              repaint();
          }// end mouseDragged
      };
  } // End Mouse Listener Block
  
  // Stores all the data required to build entire canvas
  public void loadCanvas(ArrayList&lt;ArrayList&lt;Point&gt;&gt; newLines, ArrayList&lt;Color&gt; newColors, ArrayList&lt;Integer&gt; newThickness){
      System.out.println("RECEIVED CANVAS");
      this.lines = newLines;
      this.colorList = newColors;
      this.thicknessList = newThickness;
      repaint();
  }
  
  // Sends all of the data required to build entire canvas
  public void sendCanvas(int id){
      System.out.println("SENDING CANVAS");
      ArrayList&lt;Object&gt; temp = new ArrayList&lt;Object&gt;();
      temp.add(lines);
      temp.add(colorList);
      temp.add(thicknessList);
      temp.add(id);
      try {
          chat.sendToServer(new Envelope("draw", temp));
      } catch (IOException e1) {
          System.out.println("Error sending canvas");
      }
  }
  
  // Adds new blank line to hold points, updates attributes
  public void addLine(){
      lines.add(new ArrayList&lt;Point&gt;());
      colorList.add(color);
      thicknessList.add(thickness);
  }
  </code></pre>