要隐藏(使不可见)TableColumns 通常这样做:
TableColumn.setMinWidth(0);
TableColumn.setMaxWidth(0);
或使用 removeColumn 方法(列)从模型中删除;
但是在运行时,我们需要使列不可见或可见,最终使用setMinWidth (0) 和 setMaxWidth (0)更加实用。
这会产生一个问题,因为如果用户选择表格行并按Ctrl+C并将其粘贴到文本文件中,它可以复制隐藏列的值!!!
我们可以使用TransferHandler不执行 JComponent 的 CopyAction来解决问题。如何 TableColumn is not a JComponent 不会给出以这种方式解决的。
另一种选择是定义:(JTable 禁止选择行)
JTable.setRowSelectionAllowed(false)
Well this last solution would not be feasible for me because I need to keep the permit selection of rows in the table. Does anyone have another solution to restrict copying of values from all the columns?