Not strictly a mainframe topic, I know, but this has been such a pain in the ass to figure out that I want to save others from the nonsense I had to go through to work this out.
-=THE SITUATION=-
You have a Java table with a custom renderer that allows for the text in cells to word-wrap, thus altering the height of some of the table rows. You want to serialize this table model and you get a java error regarding a sizeSequence.
-=WHAT'S GOING ON=-
Basically, the problem is that Java is dumb. When you execute the setRowHeight method for the table in question, it should be updating the SizeSequence (the thing that keeps track of where one row ends and another begins), but it's not. Not a problem until you try to serialize the table and Java freaks out because there is a discrepancy.
-=THE FIX=-
Put this line:
[table model].fireTableDataChanged();
just prior to your attempt to serialize. It'll force Java to do what it should've done in the first place, which is update SizeSequence, and allow you to serialize your table.
Tuesday, September 28, 2010
Subscribe to:
Posts (Atom)