title: Manipulate a single element of vector
body: <p>I'm currently trying to manipulate a single element of a vector in Java. If I try to do this with elementAt(i) or get(i) in a loop, the whole vector is still changed. I'm looking for a way to try and do this while still using vectors (as I use them throughout the rest of my program).</p>
  
  <p>I have tried to clone my vector into a temporary one, then remove all elements of the vector except the one to be manipulated, but to no avail.</p>
  
  <p>Here is my code segment:</p>
  
  <pre><code>@Override
  public void paintComponent(Graphics g) {
      super.paintComponent(g);
  
      Graphics2D g2 = (Graphics2D) g;
      for (int i = 0; i &lt; shapes.size(); i++) {
          if (shapes.get(i) != null){
              g2.setColor(colorSelected());
              if(fill.isSelected() &amp;&amp; !((String)shapesList.getSelectedItem() == "Line")){
                  g2.fill(shapes.elementAt(i));
              } else {
                  g2.draw(shapes.elementAt(i));
              }
          }
      }
  }
  </code></pre>
  
  <p>The problem that's happening is I'm trying to either fill/draw/change the color of the single next element drawn in my makeshift paint program, but it changes every shape.</p>
  
  <p>Any tips (or an explanation as to why this is happening) would be greatly appreciated.</p>