隐藏JTable临时列 [英] Hide column in JTable temporary

查看:83
本文介绍了隐藏JTable临时列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在使用JTable从数据库显示数据,我想通过Jcombobox过滤我的jtable.我正在使用Jcombo框,其中包含诸如030,024.045之类的值.这些值已在jtable中设置为列标题.当我单击组合时,所选的列标题将显示在jtable中,其他列应隐藏.请给我一些建议.我还在jtable中使用表模型侦听器,因为我必须在jtable中执行更新.

I am using JTable to show data from database now I want to filter my jtable by Jcombobox. I am using Jcombo box which contains the value like 030,024.045 and so on. and these values has set in jtable as column header. when I click on combo then selected column header will show in jtable and other column should be hide.Please give me some advices. I'm also using table model listener in jtable because I have to perform updation in jtable.

推荐答案

JTable t;
TableColumnModel m=t.getColumnModel();
TableColumn col=m.getColumn(columnIndex);
List<TableColumn> removed;
removed.add(col);
m.removeColumn(col);

当您想重新添加该列时,请从removed列表中获取并使用

When you would like to add the column back get it from the removed list and use

m.addColumn(col);

这篇关于隐藏JTable临时列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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