title: Moving undecorated JFrame using mouse event and thread to update
body: <p>I tend to move my undercoated <code>JFrame</code>s quite clumsily, by using creating a static reference to then a mouse event to update the <code>Point</code> location.</p>
  
  <p>So In an attempt to better understand Threads , I want to move around a very simple undercoated <code>JFrame</code> as follows:</p>
  
  <ul>
  <li>create <code>JFrame</code></li>
  <li>add <code>MouseListener</code></li>
  <li>onMousePressed: <code>Point p = Mousevent.getPoint();</code></li>
  <li>onMouseReleased: <code>Point p = Mousevent.getPoint();</code></li>
  </ul>
  
  <p>and at the same time have a thread constantly update the <code>JFrame</code>s location.</p>
  
  <p>However I cant figure out why the controllerThread, wont do more than one iteration? Also an explanation to why the below code is terrible would be very much appreciated.</p>
  
  <pre><code>public AnimationStation() throws HeadlessException {
      P=this.getLocation();
      run();
  
      class ControllerThread extends Thread{
          JFrame j;
          public ControllerThread(JFrame j){
              this.j = j;
  
          }
          @Override
          public void run(){
              this.j.setLocation(P);
          }
      }
      ControllerThread ct = new ControllerThread(this);
      ct.run(); 
      //ct.start();
  
  
  }
  
   @Override
  public void run() {
      this.setSize(d);
      Container cp = this.getContentPane();
      P=this.getLocation();
      this.setUndecorated(true);
      this.setVisible(true);
      this.setAlwaysOnTop(true);
      this.addMouseListener(new MouseListener() {
  
          @Override
          public void mouseClicked(MouseEvent me) {
             P = me.getPoint();
          }
  
          @Override
          public void mousePressed(MouseEvent me) {
              P = me.getPoint();
          }
  
          @Override
          public void mouseReleased(MouseEvent me) {
              P = me.getPoint();
          }
  
          @Override
          public void mouseEntered(MouseEvent me) {
  
          }
  
          @Override
          public void mouseExited(MouseEvent me) {
  
          }
      });
  
  
  }
  </code></pre>