I am forced to remove the rectangle caching in JTable.getCellRect,
because the
user applications do not run properly when this method reuses the same
rectangle to return the value.
The following user code:
// Repaint this row.
Rectangle a = getCellRect(row, 0, true);
Rectangle b = getCellRect(row, getColumnCount() - 1, true);
Rectangle repaint = a.union(b);
repaint(repaint);
does not compute the union and fails to repaint the row correctly.
Despite it
would be very easily to fix the user code, our purpose is to build the
library
on that java applications would run without any adaptations.
Caching rectangles reduces tha garbage production, but it seems that in this
case we have no choice.
2006-04-18 Audrius Meskauskas <[EMAIL PROTECTED]>
* javax/swing/JTable.java (getCallRect): Do not cache rectangles.
(moveToCellBeingEdited): Do not clone the rectangle here.
Index: JTable.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.95
diff -u -r1.95 JTable.java
--- JTable.java 5 Apr 2006 15:10:23 -0000 1.95
+++ JTable.java 18 Apr 2006 08:54:31 -0000
@@ -2053,9 +2053,6 @@
int column,
boolean includeSpacing)
{
- // moveToCellBeingEdited expects the cached value and clones it.
- // If the caching would be removed later, uplate moveToCellBeingEdited
- // as well.
int height = getRowHeight(row);
int width = columnModel.getColumn(column).getWidth();
int x_gap = columnModel.getColumnMargin();
@@ -2069,12 +2066,14 @@
for (int i = 0; i < column; ++i)
x += columnModel.getColumn(i).getWidth();
+
+ Rectangle rect = new Rectangle();
if (includeSpacing)
- rectCache.setBounds(x, y, width, height +y_gap);
+ rect.setBounds(x, y, width, height +y_gap);
else
- rectCache.setBounds(x, y, width - x_gap, height);
- return rectCache;
+ rect.setBounds(x, y, width - x_gap, height);
+ return rect;
}
public void clearSelection()
@@ -3722,8 +3721,7 @@
private void moveToCellBeingEdited(Component component)
{
Rectangle r = getCellRect(editingRow, editingColumn, true);
- // Clone rectangle as getCellRect returns the cached value.
- component.setBounds(new Rectangle(r));
+ component.setBounds(r);
}
/**