title: How to move a button towards another button automatically?
body: <p>I want to move a button towards another button automatically. please help me out to solve this I just learned sleep method . may some problems their applying </p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  public class tr extends JFrame
  {
  public static void main(String []args)
  {
  JFrame f1=new JFrame("Hit &amp; Run");
  JPanel p1=new JPanel();
  JButton mv = new JButton();
  JButton hit=new JButton("Hit It");
  f1.getContentPane().add(p1);
  int x;
  for(x=0;x&lt;=600;x++)
  { try{
  Thread.sleep(50); 
  }
  catch(InterruptedException e)
  {
  System.err.println("sleep exception");
  }
  mv.setBounds(x,220,53,35);
  }
  hit.setBounds(680,30,90,500);
  p1.setBackground(Color.black);
  
  hit.setBackground(Color.green);
  mv.setBackground(new Color(255,204,0));
  p1.setBackground(Color.black);
  p1.setLayout(null);
  p1.add(mv);
  p1.add(hit);
  
  f1.setVisible(true);
  f1.setSize(800,600);
  f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  }
  </code></pre>