Is there any way to determine the column name by column header using Java JTable component? E.G., I could have column header like “Header” and column name “Column”. And I’m looking for a method like Column_Name_From_Header(“Header”) -> “Column”.
Is there any way to determine the column name by column header using Java
Share
Iterate through the table columns of the table’s column model. Find the one with the given header value (using
headerValue.equals(tableColumn.getHeaderValue()). Then ask themodelIndexof the column (tableColumn.getModelIndex()), and ask the table’s model for the column name at this index :tableModel.getColumnName(index).