如何在JTable上使用TableColumnAdjuster获得最大列宽
问题描述:
TableColumnAdjuster
是一个很棒的工具,但我似乎无法让表格显示每列的完整宽度.我看不到整个标题,有时可能会很长.
The TableColumnAdjuster
is a great tool, but I just can't seem to get the table to show the full width of each of the columns. I can't see the whole header, which can sometimes be quite long.
这就是我所拥有的:
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnAdjuster tca = new TableColumnAdjuster(table);
tca.adjustColumns();
tca.setColumnHeaderIncluded(true);
tca.setColumnDataIncluded(true);
tca.setOnlyAdjustLarger( true );
tca.setDynamicAdjustment( false );
,但除非我手动调整大小,否则列标题已部分隐藏.关于如何显示列的整个宽度的任何想法,以便我可以看到整个标题?
but the column header is partially hidden unless I manually resize. Any ideas about how to show the full width of the column so I can see the whole header?
答
setDynamicAdjustment(true); //false will work for the static data
you might wann change it to `true`.
设置属性后,
在最后调用adjustColumns()
.