title: How to change position of a JLabel?
body: <p>I'm trying to use a timer to change the position of a JLabel, from one spot on my JPanel to another. I'm not sure if I could use say <code>.getLocation()</code>, then change only the horizontal x value, and finally use <code>.setLocation()</code> to effectively modify the JLabel. I've also used <code>.getBounds</code> and <code>.setBounds</code>, but am still unsure how I can obtain the old horizontal x value to change and reapply to the new x value. </p>
  
  <p>The code I tried looks something like this, but neither is a valid way to change the position of the JLabel.</p>
  
  <pre><code>// mPos is an arraylist of JLabels to be moved.
  
  for(int m = 0; m &lt; mPos.size(); m++){
          mPos.get(m).setLocation(getLocation()-100);
      }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>    for(int m = 0; m &lt; mPos.size(); m++){
          mPos.get(m).setBounds(mPos.get(m).getBounds()-100);
      }
  </code></pre>
  
  <p>If I could just get the position of the horizontal x value I can change the position of the label. </p>