When JTable has hidden columns, how to get the real column index when getting the selected columns?

  java, question

When JTable has hidden columns, use thegetSelectedColumns()The column index obtained is the column index displayed in the interface. If this table contains hidden columns, how do I get the real column index?
Such as 0 (hidden) 1 (hidden) 2 (visible) 3 (visible) 4 (visible) 5 (visible) 6 (visible)
As follows:

clipboard.png

Selected
UsegetSelectedColumns()Gets the column index of [0, 1, 2, 3, 4]
In fact, what I want to get is the real index [2, 3, 4, 5, 6].
How should this be achieved?

TableColumn tc = tcm.getColumn(column)
 tcm.removeColumn(tc);  //Do not use this method to hide columns
 
 //Set the length and width of the column to be hidden to 0, which also realizes hiding.  And you can normally use getValueAt () to get cell values.
 tc.setMinWidth(0);
 tc.setMaxWidth(0);