title: Convert ArrayList to DefaultListModel
body: <p>I'm beginner in Java. I really need to return <code>DefaultTableModel</code> (<code>javax.swing</code>) from array or <code>ArrayList</code>. It is possible? I can't insert array into <code>DefaultTableModel</code> (constructor). </p>
  
  <p>Code is below:</p>
  
  <pre><code>private DefaultListModel model;
  
  
  public DefaultListModel getNamesAndIdToCombobox(Connection conn, boolean closeConn, String sql) throws SQLException {
  
      long counter = 0;
  
      try {
          Statement stmt = 
                  conn.prepareStatement(sql);
          ResultSet rs = stmt.executeQuery(sql);
  
          while (rs.next()) {
              // String longKey = (String)rs.getString(2);
              try
              {
                  jListList.add(new JListValues(rs.getLong(2), rs.getString(1)));
              }
              catch(SQLException sqlException){}
  
              try
              {
                  jListList.add(new JListValues(rs.getLong(2), rs.getLong(1)));
              }
              catch(SQLException sqlException){}
  
              try
              {
                  jListList.add(new JListValues(rs.getString(2), rs.getLong(1)));
              }
              catch(SQLException sqlException){}
              counter++;
  
          }
          JListValues[] array = jListList.toArray(new JListValues[jListList.size()]);
  
  
          model = new DefaultListModel(array);       // HERE IT IS A PROBLEM
  
          LOGGER.info("getNamesAndIdToCombobox result count: " + counter);
      } catch (SQLException e) {
          LOGGER.error("Error", e);
          throw e;
      } finally {
          try {
              if (closeConn == true)
                  conn.close();
          } catch (Exception e) {/* null */
          }
      }
      return model;
  }
  </code></pre>