title: A label or any component that moves from one place to another in JFrame
body: <p>I am trying to move an label/icon &amp; button from one place to another place using <code>setLocation</code> method but for some reason the objects are moving but not in motion. So if any one knows how to do this thing please tell me. </p>
  
  <p>How to create a label or any component that moves from one place to another place in JFrame?</p>
  
  <p>Below I have shown the code:</p>
  
  <pre><code>jl = JLabel
  jf = JFrame
  
      public void actionPerformed(ActionEvent e) 
      {
          if(e.getSource()==jbtn)
          {
              for(int i=0;i&lt;=30;i++)
              {
                  jl.setLocation(100,100+i);
                  jl.repaint();
                  jf.repaint();
                  try
                  {
                      Thread.sleep(50);
                  }
                  catch(Exception ae)
                  {
                      ae.printStackTrace();
                  }
              }
          }
      }
  </code></pre>