title: Jpanel calling a thread
body: <p>I'm calling this class from another class with setContentPane(new Gamepanel()).
  Why the thread t1 is not calling the run method?</p>
  
  <pre><code>public class GamePanel extends JPanel implements Runnable {
  
      public static int WIDTH = 1024;
      public static int HEIGHT = WIDTH / 16 * 9;
      private Thread t1;
      boolean running;
  
  
      public void addNotify(){
          Dimension size = new Dimension(WIDTH,HEIGHT);
          setPreferredSize(size);
          running = true;
          t1.start();
      }
  
  
      public void paintComponent (Graphics g){
          g.setColor(Color.WHITE);
          g.fillRect(0, 0, WIDTH, HEIGHT);
          g.setColor(Color.BLACK);
          g.fillOval(200, 200, 50, 50);
      }
  
  
      public void run() {
          while (running){
              System.out.println("Runs");
      }
  }
  </code></pre>
  
  <p>EDIT</p>
  
  <p>Well, in fact initializing the Thread did the trick. Like that</p>
  
  <pre><code>public class GamePanel extends JPanel implements Runnable {
  
      public static int WIDTH = 1024;
      public static int HEIGHT = WIDTH / 16 * 9;
      private Thread t1;
      boolean running;
  
  
      public void addNotify(){
          Dimension size = new Dimension(WIDTH,HEIGHT);
          setPreferredSize(size);
          running = true;
          t1 = new Thread(this);
          t1.start();
       }
  
  
  
      public void paintComponent (Graphics g){
              g.setColor(Color.WHITE);
          g.fillRect(0, 0, WIDTH, HEIGHT);
          g.setColor(Color.BLACK);
          g.fillOval(200, 200, 50, 50);
       }
  
  
       public void run() {
           while (running){
           System.out.println("Runs");
           }
  
       }
  
  }
  </code></pre>
  
  <p>I was assuming that this was a right way to start putting a game loop in the start method.
  I'm planning to go JFrame+JPanel+threaded game loop (input+update+draw).Am I wrong?</p>