简体   繁体   English

如何忽略JTable中TableModel的列?

[英]How to ignore a column of a TableModel in a JTable?

I have a TableModel to a JTable and I must put it on another table, and I've done it just seting the model of the second table with setModel(firstTableModel) . 我有一个JTableTableModel ,我必须将它放在另一个表上,而我只用setModel(firstTableModel)设置了第二个表的模型就完成了。

The problem is that I don't want that one of the columns of the model shows on the second table. 问题是我不希望模型的列之一显示在第二张表上。

Is it possible to ignore/not display a single column, or I really must create another TableModel with all the redundant information of the first table model to omit just a single column? 是否可以忽略/不显示单个列,或者我真的必须创建一个具有第一个表模型的所有冗余信息的TableModel来省略单个列?

感谢@mKorbel,我找到了解决方案:

secondTable.removeColumn(secondTable.getColumnModel().getColumn(columnIndex));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM