title: Retrieve data from MongoDB collection into Swing JTable
body: <p>I am a newbie in database projects. 
  I don't know how to display a collection in mongodb inside a swing window (EDIT: JTable) after connecting it to the database server....plz help me out in this...
  I have tried doing this in sql but am not able to do using mongodb</p>
  
  <pre><code>JButton btnDisplay = new JButton("display");
      btnDisplay.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              try {
                  // To connect to mongodb server
                  MongoClient mongoClient = new MongoClient( "localhost" , 27017 );
                  // Now connect to your databases
                  DB db = mongoClient.getDB( "test" );
                  System.out.println("Connect to database successfully");
  
                  DBCollection coll = db.getCollection("cars");
                  DBCursor cursor = coll.find();
              }
  
              catch (Exception a) {
                  a.printStackTrace();
              }
          }
      });
  </code></pre>