title: How to Start a Java MVC Application With a Swing GUI
body: <p>Let us assume we have a simple Java MVC Application with the classes <code>Model</code>, <code>View</code> and <code>Controller</code>. The <code>View</code> class directly inherits from <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html" rel="nofollow noreferrer"><code>JFrame</code></a>. As in a <a href="https://upload.wikimedia.org/wikipedia/commons/b/b5/ModelViewControllerDiagram2.svg" rel="nofollow noreferrer">classic MVC setup</a>, the view has a reference to the model and the controller has a reference to the view and to the model.
  As I just learnt, all GUI-related stuff should be wrapped in a <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingUtilities.html#invokeLater%28java.lang.Runnable%29" rel="nofollow noreferrer"><code>SwingUtilities.invokeLater</code></a> or something similar. Now what is the right way to initialise/start this application? I think the creation of the model and the controller should not be inside of the EDT, right? So I would come up with something like this:</p>
  
  <pre><code>final Model model = new Model();
  SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
          final View view = new View(model);
          new Thread(new Runnable() {
              @Override
              public void run() {
                  new Controller(model, view);
              }
          }).start();
      }
  });
  </code></pre>
  
  <p>Is this the correct way and a good idea or are there better possibilities?</p>
  
  <p>EDIT:
  As correctly stated by @trashgod, a related example is examined <a href="https://stackoverflow.com/a/3072979/230513">here</a>. Then I extend my question: What is basically done there is the following:</p>
  
  <pre><code>SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
          Model model = new Model();
          View view = new View(model);
          new Controller(model, view);
      }
  });
  </code></pre>
  
  <p>But isn't it wrong to run the whole application in the EDT?</p>