title: How to correctly implement MVC in Java with Swing?
body: <p>If you would like more details please let me know, or refer to the last lines of this question. I've already read a lot and I feel I'm turning something simple into something complicated and I still get stuck here and there, so maybe you can help me in those very specific points. </p>
  
  <p>I'm using Netbeans IDE 7 and JDK 7, and no frameworks. The first Window is a JFrame and all other windows are JDialogs with modal=true.</p>
  
  <p>Questions:</p>
  
  <ol>
  <li><p>How do I correctly implement the MVC pattern with swing?
  From the ideas bellow Which one is better: (A) or (B)? Or maybe another one... Why is it better?</p>
  
  <p>(A)
  Main: </p>
  
  <pre><code>MyModel model
  MyView view(model)
  </code></pre>
  
  <p>MyView:</p>
  
  <pre><code>MyController(this, model)
  </code></pre>
  
  <p>(B)<br>
     Main:</p>
  
  <pre><code>MyModel model
  MyView View
  MyController controller(view, model)
  </code></pre></li>
  <li><p>when I click jbutton1 in MainFrame I need it to open the SettingsFrame for editing settings. where should I instantiate the View, the Model and the Controller of the SettingsFrame? In MainFrame Controller?</p></li>
  <li><p>In terms of MVC organization and implementation, how should I handle more specific features that (apparently) lacks one or two of the MVC "legs" (either Model or View or Controller)? Should I create empty classes for them?</p>
  
  <pre><code>a. The implementation of a TrayIcon
  b. A URL connection class (an HttpsUrlConnection which will update data in the main jframe and also upload/download files)
  c. A Directory Monitor (which will update data in the main jframe and also use the urlconnection to download a file)
  d. My own implementation of TableModel
  e. json
  </code></pre></li>
  <li><p>How to correctly keep and use an object with settings through the whole application? I will need it's information in different places (Views, Models, Controllers) but it might be altered by user during the runtime). Is it a good idea to make this model a singleton?</p></li>
  <li><p>What should I do when:</p>
  
  <pre><code>a. View needs some data from the Model? 
  What I'm doing: using the reference of Model which I keep in the View
  b. View needs some data from the Controller?
  What I'm doing: using the reference of Controller which I keep in the View
  c. Model needs some data from the Controller?
  Still didn't happen but I have no idea how to do correctly
  d. Model needs some data from the View?
  What I'm doing: pulling all my hair from my head...
  e. Controller needs some data from the View?
  What I'm doing: using the reference of the View which I keep in the Controller
  f. Controller needs some data from the Model?
  What I'm doing: using the reference of the Model which I keep in the Controller
  g. One of FooModel, FooView or FooController needs data from one of BarModel, BarView or BarController?
  What I'm doing: thinking of jumping from the highest building...
  </code></pre></li>
  <li><p>Any hints on how to know if I implemented MVC correctly? Should I process massive data in Model or Controller?</p></li>
  <li><p>I'm also using a DAO, what I'm doing is: my model has a </p>
  
  <blockquote>
    <p>ArrayList MyModel load()</p>
  </blockquote>
  
  <p>method which creates an instance of the DAO and returns the ArrayList of Models returned by the DAO, and then sometimes I process this ArrayList of Models in the Model and sometimes I allow the Controller to process it. Is this a good practice or is there a better way? By Process I mean: iterate through the ArrayList and get the data from the models.</p></li>
  <li><p>I Have a PasswordCheck jDialog to restrict access to some Views. How can I reuse it in terms of MVC, so that I can use the same PasswordCheck dialog for allowing/restricting access to different Views without doing a mess in the code?</p></li>
  <li><p>Any other tips, hints, ideas, suggestions? </p></li>
  </ol>
  
  <p><strong>Context:</strong>
  I'm required to develop a Java Swing MVC software in a short time, although by default I'm not a Java developer and not so used to implement the MVC pattern, specially in Java (I get the idea but sometimes it lacks me knowledge to implement the relationship between classes). 
  The applications is basically a monitor for local/online files with a JTable in the main frame to show this data. I'm using the new WatchService API to keep track of the local files and saving their info in a h2 database using a DAO, and them reload this data in the main frame jtable. I must also notify the user about new files (which for I'm using TrayIcon). For the online files monitoring/uploading/downloading I'm using HttpsUrlConnection and json. It may also allow Settings customization.</p>
  
  <p>Thanks in advance for you time and help.</p>