在 Java 抽象表模型中显示某些列 [英] Display Certain Columns in Javas Abstract Table Model

查看:21
本文介绍了在 Java 抽象表模型中显示某些列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 JRadioButtons 在我的抽象表中显示某些列.因此,我的表中有 2 列已聘用的视频"和未聘用的视频"如果单击显示所有招聘"单选按钮,然后用户单击全部显示",我只想显示其中的 1 列JRadioButton 它将显示两个列.

I'm trying to use JRadioButtons to display a certain Columns in my Abstract Table. So I have 2 Columns in my table "Videos that are hired"and "Videos not Hired" I only want to show 1 of the Columns if the "Show all Hires" radio button is clicked then if the user clicks the "Show all" JRadioButton it will show both of the Columns.

任何帮助将不胜感激.

推荐答案

Following MVCAbstractTableModel 是存储数据的模型,JTable 为模型提供视图组件.

Following MVC, an AbstractTableModel is a model whereby your data is stored and a JTable provides the view component for your model.

因此,由于您有兴趣改变数据的显示方式,您可以这样调整视图组件(JTable):

Therefore, since you are interested in changing the way the data is presented, you can adjust the view component (the JTable) as such:

TableColumn column = table.getColumn("Videos Not Hired");
table.removeColumn(column); // remove this column from the view
table.addColumn(column); // add this column to the view

这篇关于在 Java 抽象表模型中显示某些列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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