<Swing Dev> [12] RFR JDK-8202702:Clearing selection on JTable causes disappearance of a row
Prasanta Sadhukhan
prasanta.sadhukhan at oracle.com
Wed Aug 8 14:51:55 UTC 2018
Hi All,
Please review a fix for an issue where it is seen that
when clearing a selected row by calling JTable.clearSelection() causes
this selected row to be not painted.
This is because, the present BasicTableUI paint() method paints JTable
cell based on rMin and rMax value which are
the min index and max index of the rows to be painted. Now, this rMax is
decremented based on some condition due to a printing problem
where 1 extra row was printed in page than what is being shown in console.
This decrement of rMax causes rMax to become less than or equal to rMin,
when a selected row is cleared and JTable paint is called
and so when paintCells() is called, it causes skipping of row painting,
thus causing disappearance of that row.
For example, if row6 is selected and clearSelection() is called,
then rMin=rMax=6 but decrementing rMax will make it 5 so paintCells()
"for" loop to repaint the JTable cell 6 will not be executed and row6
will disappear.
Proposed fix is to check if decrementing rMax will make it lesser than
or equal to rMin, then do not decrement rMax, so that rows can be
painted properly.
Previous JDK-8081491 and JDK-8159068 testcases works well after this change.
Bug: https://bugs.openjdk.java.net/browse/JDK-8202702
webrev: http://cr.openjdk.java.net/~psadhukhan/8202702/webrev.0/
Regards
Prasanta
More information about the swing-dev
mailing list