This borrows most of the logic from the superclass handling of update events, but changes the calculation of the height for the dirty region to provide proper handling for repainting custom height rows. Copied from <a href="http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow
(TableModelEvent e)
| 957 | * Copied from <a href="http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/">this page</a>. |
| 958 | */ |
| 959 | private void handleRowUpdate(TableModelEvent e) { |
| 960 | int modelColumn = e.getColumn(); |
| 961 | int start = e.getFirstRow(); |
| 962 | int end = e.getLastRow(); |
| 963 | |
| 964 | Rectangle dirtyRegion; |
| 965 | if (modelColumn == TableModelEvent.ALL_COLUMNS) { |
| 966 | // 1 or more rows changed |
| 967 | int rowStart = 0; |
| 968 | for ( int row=0; row < start; row++ ) rowStart += getRowHeight(row); |
| 969 | dirtyRegion = new Rectangle(0, rowStart, |
| 970 | getColumnModel().getTotalColumnWidth(), 0); |
| 971 | |
| 972 | } else { |
| 973 | // A cell or column of cells has changed. |
| 974 | // Unlike the rest of the methods in the JTable, the TableModelEvent |
| 975 | // uses the coordinate system of the model instead of the view. |
| 976 | // This is the only place in the JTable where this "reverse mapping" |
| 977 | // is used. |
| 978 | int column = convertColumnIndexToView(modelColumn); |
| 979 | dirtyRegion = getCellRect(start, column, true); |
| 980 | } |
| 981 | |
| 982 | // Now adjust the height of the dirty region |
| 983 | dirtyRegion.height = 0; |
| 984 | for (int row = start; row <= end; row ++ ) { |
| 985 | //THIS IS CHANGED TO CALCULATE THE DIRTY REGION HEIGHT CORRECTLY |
| 986 | dirtyRegion.height += getRowHeight(row); |
| 987 | } |
| 988 | repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height); |
| 989 | } |
| 990 | |
| 991 | |
| 992 | /** |
no test coverage detected