如何在JTable Invisible for Swing Java中创建一个列 [英] How to make a columns in JTable Invisible for Swing Java
本文介绍了如何在JTable Invisible for Swing Java中创建一个列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我设计了一个GUI,其中我使用了一个JTable,我必须从中使2个列不可见。我应该怎么做?
I have designed one GUI in which I have used one JTable from which I have to make 2 columns invisible . How should I do that ?
推荐答案
从<删除 TableColumn
code> TableColumnModel 。
Remove the TableColumn
from the TableColumnModel
.
TableColumnModel tcm = table.getColumnModel();
tcm.removeColumn( tcm.getColumn(...) );
如果您需要访问数据,那么您使用 table.getModel() .getValueAt(...)
。
If you need access to the data then you use table.getModel().getValueAt(...)
.
对于允许用户隐藏/显示列的更复杂的解决方案,请查看表格栏管理员。
For a more complex solution that allows the user to hide/show columns as they wish check out the Table Column Manager.
这篇关于如何在JTable Invisible for Swing Java中创建一个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文