Select 全部相同的jtable值一键点击

Select all Same jtable value in one click

我正在为我的项目创建工资单的原型,我想问一下,我如何 select 只需单击一个 table 中具有相同名称和员工 ID 的所有值他们中的?所有 selected 行都将传递给另一个 table。请帮助我,我只是不知道该怎么做?

How can i select all value with the same name and Employee's id

首先,我建议员工的 ID 是唯一的,因此您需要在 table 中搜索所选 ID。

最简单的方法是根据员工的 ID "filter" table。阅读 Sorting and Filtering 上的 Swing 教程部分。该工作示例展示了如何在您将文本键入文本字段时进行动态搜索。

And all the selected row will pass to another table

现在您在 table 中拥有所有过滤后的数据,您只需使用 getValueAt(...) 方法遍历 JTable 来获取您想要的数据并将数据添加到另一个 JTable 使用那个 table 的 DefaultTableModeladdRow(...) 方法。