title: How MVC work with java swing GUI
body: <p>Lets say I have a swing GUI which has textfeild and button. When I click button I want to save that value in text in db and return joptionpane "success" message. 
  <br/>
  The way I used to do this is 
  <br/>
  <strong><em>Model</strong> : JDBC class</em>
  <br/>
  <strong><em>View</strong> : GUI</em> : In that button's '<em>action performed</em>' action I call save method with parameter. <br/></p>
  
  <pre><code>   Controller con = new Controller();
     con.save(text1.getText());
  </code></pre>
  
  <p><strong><em>Controller</strong> : Write a save method.</em></p>
  
  <pre><code>   JDBC db = new                             
     public void save(jTextfeild text){     
     text= text1.getText();
     boolean b= db.putData("insert into .. values(text)");
     if(b){
     JOptionPane("Success"); 
     }
   }
  </code></pre>
  
  <p><br/>
  This is how I started. But later I understood this is not how this should be and this is utterly unsafe and stupid. 
  <br/>
  I really want to learn how to do this in MVC properly. Please be kind enough to explain this to with a small example. Thank you for your time. </p>