-
Bug
-
Resolution: Fixed
-
P5
-
1.3.0
-
merlin
-
generic, sparc
-
generic, solaris_2.6
Name: aaC67449 Date: 11/01/99
The behavior of TableColumn.sizeWidthToFit() method was changed in JDK1.3.0M.
The method does not change minimum and maximum width of the TableColumn now.
See example.
It is incompatible change, the old behavior should be restored.
the javadoc 1.2.2, 1.3.0K says: "
public void sizeWidthToFit()
Resizes the TableColumn to fit the width of its header cell. If the maximum
width is less than the width of the header, the maximum is increased to the
header's width. Similarly, if the minimum width is greater than the width of
the header, the minimum is reduced to the header's width.
See Also:
setPreferredWidth(int)
"
the javadoc 1.3.0M says: "
sizeWidthToFit
public void sizeWidthToFit()
Resizes the TableColumn to fit the width of its header cell.
This method does nothing if the header renderer is null
(the default case).
See Also:
setPreferredWidth(int)
"
------------------------- example1 ----------------
import javax.swing.*;
import java.awt.*;
import javax.swing.table.*;
public class Test {
public static void main(String argv[]) {
TableColumn c = new TableColumn();
c.setHeaderRenderer(new TestCellRenderer());
c.sizeWidthToFit();
if (!(c.getMinWidth() <= 10 && c.getMaxWidth() >= 10
&& c.getWidth() == 10 )) { // verify setting
System.out.println("The method works incorrectly. width="
+ c.getWidth()+" Should be 10");
} else {
System.out.println("Passed");
}
}
}
class TestCellRenderer implements TableCellRenderer {
Component comp = null;
public TestCellRenderer() {
comp = new TestComponent();
}
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
return comp;
}
}
class TestComponent extends Component {
public TestComponent() {
super();
}
public Dimension getPreferredSize() {
return new Dimension(10, 10);
}
public Dimension getMinSize() {
return new Dimension(10, 10);
}
public Dimension getMaxSize() {
return new Dimension(10, 10);
}
}
-------------------- JDK1.3.0M -------------------
The method works incorrectly. width=15 Should be 10
------------------------- JDK1.3.0K, JDK1.2.2W ----------------
Passed
======================================================================