-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.2.2
-
generic
-
generic
Name: skT45625 Date: 08/14/2000
java version "1.2.2.Symc"
Classic VM (build 1.2.2.Symc, native threads, symantec gc, symcjit)
I created my own TableColumnModel and inherited from DefaultTableColumn.
In the constructor I filled the rows like this:
public DocumentColumnModel() {
setColumnMargin(1);
setColumnSelectionAllowed(false);
for(int i = 0; i < _header.length; i++) {
TableColumn col = new TableColumn(i);
col.setHeaderValue(_header[i].getName());
col.setMinWidth(_header[i].getWidth());
addColumn(col);
}
}
The JTable using this TableColumnModel was displayed in a JScrollPane and here
the problem surfaced: although the DocumentColumnModel.getTotalColumnWidth()
did show the correct width of the tablecontents but the JTable itself was way
too small and therefore I couldn't scroll to the rightmost columns.
The tables AutoResizeMode was set to JTable.AUTO_RESIZE_OFF.
The solution of this problem lies within the implementation of
TableColumn.setMinWidth(int):
public void setMinWidth(int minWidth)
{
this.minWidth = Math.max(minWidth, 0);
if (width < minWidth) {
setWidth(minWidth);
}
}
As you can see setWidth() is called if the current(?) width is smaller than the
new minWidth but the preferred width is not checked. On a side note: the
maximum width neither.
Obviously (although I haven't found the location in the source) what happens
is, that somewhere in the process of rendering the table the (unadjusted)
preferred width is used to calculate the width of the table but the real width
is used for drawing.
As a solution I would propose to do quite a bunch of crosschecks more in those
TableColumn.set*Width() routines.
(Review ID: 108396)
======================================================================