FIXED! JTable displaying only 7 rows out of 409

75 views Asked by At

I have a JTable, in a JScrollPane, where I want to display all the rows from a MySQL table. The "tr.getTransList()" gets the rows I want and returns the ResultSet for DbUtils use. Column names are set properly. The only problem is that I can only scroll over seven rows, because it's showing only seven rows. I love the ease of use with DbUtils.resultSetToTableModel(rs) and would prefer to be able to keep using it. I have the method below, in its entirety. The print statements output 409 and 12 for the first two, and 409 for the third print statement.

So, why am I only seeing 7 rows onscreen?

I am using NetBeans 7.3 and I have no rows or columns set in the table in the design mode. I've tried setting 50 rows and 99 rows (the max it lets me use), but there is no difference -- I still only get 7 rows. I cannot see any settings in the scrollpane or the jtable that would limit this, but I'm still a pretty new Java programmer.

The line that is commented-out is the one I used originally, the following lines were not there. I added them so I could print the info from the model.

 private void populateLastTrans() {
     ResultSet rs;

     rs = tr.getTransList();

     // lastTransTable.setModel(DbUtils.resultSetToTableModel(rs));
     TableModel model = DbUtils.resultSetToTableModel(rs);
     System.out.println("rowCount: " + model.getRowCount());
     System.out.println("colCount: " + model.getColumnCount());

     lastTransTable.setModel(model);
     System.out.println("rows: " + lastTransTable.getRowCount());
    }

I don't believe it's in the SQL query because I get all 409 rows in mysql client, but just in case, here is the query I use:

SELECT 
 trans_id AS Trans, head AS Head, weight AS Weight, buyerID AS Buyer, 
 sellerID AS Seller, descrip AS Description, price AS Bid, 
 mode AS Mode, TRUNCATE(weight/head, 0) AS AvgWgt, amount AS TotalCost, 
 IF(mode IN (1,3,5,7),TRUNCATE(price*(weight/100)/head,2),price) AS ByHD, 
 IF(mode IN (1,3,5,7),price,TRUNCATE(price/(weight/head)*100,2)) AS ByCWT
 FROM trans WHERE date=(SELECT MAX(start) FROM sales WHERE sel=1) 
 ORDER BY trans_id DESC
1

There are 1 answers

0
Kevin Nathan On

Fixed! I deleted the scrollpane and jtable (for the third time) and it started working again. There must have been something I set in the jtable or scrollpane that messed it up, but I sure cannot see what it could be...