cam*_*ckr 34
确定行高度的唯一方法是渲染每个单元格以确定渲染高度.在您的表填充数据后,您可以执行以下操作:
private void updateRowHeights()
{
for (int row = 0; row < table.getRowCount(); row++)
{
int rowHeight = table.getRowHeight();
for (int column = 0; column < table.getColumnCount(); column++)
{
Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column);
rowHeight = Math.max(rowHeight, comp.getPreferredSize().height);
}
table.setRowHeight(row, rowHeight);
}
}
Run Code Online (Sandbox Code Playgroud)
如果只有第一列可以包含多行,则只能优化该列的上述代码.
| 归档时间: |
|
| 查看次数: |
27854 次 |
| 最近记录: |