如何在JTable上使用TableColumnAdjuster获得最大列宽 [英] How to get the maximum column width using TableColumnAdjuster on a JTable

查看:48
本文介绍了如何在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().

这篇关于如何在JTable上使用TableColumnAdjuster获得最大列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆