Results 1 to 3 of 3
  1. #1
    toymachiner62 is offline Member
    Join Date
    Oct 2009
    Posts
    63
    Rep Power
    0

    Post Populating a JTable

    I'm trying to populate my JTable. I have 3 rows in the table and it's populating one row 3 times. What's wrong with my loop?

    Java Code:
    while(rs.next()) {
                  
                  int count;
    
                  for(int i=0; i < numRows; i++) {
                      count = 1;
                      
                      for(int j=0; j < numCols; j++) {
    
                          familyTable.setValueAt(rs.getString(count), i, j);
                          
                          count++;
                      }
                }

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

    Default

    Because every time you read one row from the ResultSet, you update all three rows in the TableModel. So all three rows will contain the values from the last row read in the ResultSet.

  3. #3
    toymachiner62 is offline Member
    Join Date
    Oct 2009
    Posts
    63
    Rep Power
    0

Similar Threads

  1. Populating the values in text fields
    By Inaam in forum Web Frameworks
    Replies: 2
    Last Post: 07-26-2010, 08:55 AM
  2. Populating a gui list box with the files in a directory
    By josejvelezcolon in forum New To Java
    Replies: 1
    Last Post: 08-10-2009, 04:50 PM
  3. Error when populating the data
    By srinivas_k543 in forum Java Servlet
    Replies: 2
    Last Post: 07-10-2009, 08:29 AM
  4. Populating JTree With Directory Info
    By SilentCodingOne in forum AWT / Swing
    Replies: 0
    Last Post: 07-07-2009, 02:37 PM
  5. Pre-Populating an Outlook Email
    By KeithHenn in forum Advanced Java
    Replies: 3
    Last Post: 10-23-2008, 03:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •