如何获得JTable标头以显示整个列名而不是缩短它们? [英] How do I get a JTable header to display entire column names instead of shortening them?

查看:101
本文介绍了如何获得JTable标头以显示整个列名而不是缩短它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JTable,其中填充了扩展AbstractTableModel的类.问题是列太短而无法显示列名.我已关闭了Jtable AutoResizeMode属性,但仍会发生缩短.我该如何解决?

I've a JTable that I fill with a class that extends AbstractTableModel. The problem is that the columns are too short to display the column name. I've turned off Jtable AutoResizeMode property, but shortening still occurs. How do I solve this?

推荐答案

设置autoresizemode只能防止调整JTable的列大小.要强制使用特定宽度,请检索表列模型:

Setting off autoresizemode only prevent the JTable's coumns to be resized. To force a particular width retrieve the table column model:

TableColumn column = jtable.getColumnModel().getColumn(col_num);

并设置所需的宽度:

column.setPreferredWidth(width);

这篇关于如何获得JTable标头以显示整个列名而不是缩短它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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