title: How to add JSON data to a JTable in JAVA
body: <p>I am using REST webservice to access the MySQL database. I have created a java swing application for REST client in NetBeans IDE. When I clicked <code>jButton</code> I am getting <code>JSON object</code> and I set those to a <code>jTextArea</code>. Now what I want is to fill the <code>JTable</code> from the received <code>JSON object</code>. Can anybody help me? Thanks in advance.</p>
  
  <blockquote>
    <p>Code that set JSON Object to jTextArea</p>
  </blockquote>
  
  <pre><code>try {
          URL url = new URL("http://localhost:8080/webservice/rest/bdetails/get");
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          conn.setRequestProperty("Accept", "application/json");
  
          if (conn.getResponseCode() != 200) {
              throw new RuntimeException("Failed : HTTP error code : "
                      + conn.getResponseCode());
          }
  
          BufferedReader br = new BufferedReader(new InputStreamReader(
              (conn.getInputStream())));
  
          String output;
          String json = "";
          System.out.println("Output from Server .... \n");
          while ((output = br.readLine()) != null) {
              System.out.println(output);
                          json += output;
          }
  
          conn.disconnect();
          java.lang.reflect.Type listType = new TypeToken&lt;ArrayList&lt;BDetails&gt;&gt;() {
                  }.getType();
  
          List&lt;BDetails&gt; bList = new Gson().fromJson(json, listType);
  
              for( BDetails adr : bList) {
                 jTextArea1.append(adr.toString());
                 jTextArea1.append("\n");
  
              }
  
              System.out.print(json);
          } catch (IOException | RuntimeException ex) {
              System.out.println(ex);
          } 
  </code></pre>
  
  <blockquote>
    <p>BDetails Class</p>
  </blockquote>
  
  <pre><code>public class BDetails 
  {
      private String username;
      private String firstName;
      private String lastName;
      private String address;
  
      public BDetails() {
      }
  
      public BDetails(String username, String firstName, String lastName, String address) {
          this.username = username;
          this.firstName = firstName;
          this.lastName = lastName;
          this.address = address;
      }
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public String getAddress() {
          return address;
      }
  
      public void setAddress(String address) {
          this.address = address;
      }
  
      @Override
      public String toString()
      {
          String object = "username: "+username+" firstName: "+firstName+" lastName: "+lastName+" address: "+address;
          return object;
      }
  </code></pre>