JTable row height and JScrollPane
robliOct 10 2012 — edited Oct 18 2012Using SE 6.
I have a single column JTable that renders it's rows as JPanel components. The preferred size/height of the panel in each row is based on the content of each row. In current version, the renderer is then calling back to the JTable to set the height of the row as each are rendered. All works fine except when the table contains more rows than it can display, the renderer isn't setting the heights for all the rows until the JScrollPane is used by user to bring all rows into focus. The JTable is fine with this, but the initial state/value of the scroll-bar isn't 100%, and as the user drags it down, the scrollbar 'flickers' as the JTable adjusts the height as new rows are brought into the display.
Typically aren't many rows in these JTable components (~20 odd, but that's often enough to engage the scrollbar) so would like to find a way to prepare the heights of all rows after the data is loaded rather than waiting for user to display them all. Wondered if anyone else had a solution / idea about how this might be achieved ?
Many thanks,