Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forcing JTable column widths when data is updated - where am I going wrong?

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have a JTable whose column width's I am setting before the table is visible. When the table is shown, the column are correctly sized.

When I load data into the table, the column width's change.

How do I get the column's width's to hold when the data changes? Amazingly, this is the only of the four tables on the screen that is doing this and I cannot pinpoint where the error is!

Many most kind regards,
Rachel


This is the code for setting up the table (the total's table)


This is the code that calculates the data in the table


This is the place where the new row data is put into the table model that governs the total's table
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't see anything obvious although I suspect it's the fireTableChanged(null). To debug, write a method something like this (pseudo-code).

void dumpColumnState {
for each column in column table [
print "index = " + colIndex + " width = " + width;
}
}

Sprinkle liberally around your code and find which statement is clearing your column widths.
hth, D.
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Don

I found that it was during the setting of the Object[][] rowData to the new data that was coming in. Don't know why but at least it works now!

Thanks again!
Rachel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic