Problems with copy value TableColumn invisible

96 Views Asked by At

To hide (make invisible) TableColumns normally do:

TableColumn.setMinWidth(0);
TableColumn.setMaxWidth(0);

or remove from the model with removeColumn method (column);

But at run time we have the need to leave invisible or visible the column and ends up being more practical to use setMinWidth (0) and setMaxWidth (0).

This creates a problem because if the user selects a table row and press Ctrl+C and paste it into a text file, it can copy the value of the hidden column!!!

We could to solve the problem using TransferHandler to not perform CopyAction of JComponent. How TableColumn is not a JComponent would not give to solve this way.

Another alternative would be to define: (JTable to disallow selection lines)

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?

1

There are 1 best solutions below

1
On

To hide (make invisible) TableColumns normally do:

TableColumn.setMinWidth(0);
TableColumn.setMaxWidth(0);
  • this isn't good way, playing with zero size, this column isn't hiddenonly has un_natural size, still is accesible for all mouse & key events

  • you have to removeColumn() from JTables view