我需要通过此方法更改现有JTable
的标题标题。
private JTable datatable;
public void ChangeTitleColumn(String ColumnName,String HeaderTitle){
JTableHeader th = datatable.getTableHeader();
TableColumnModel tcm = th.getColumnModel();
TableColumn tc = tcm.getColumn(0); //<---- How to refer by ColumnName
tc.setHeaderValue( HeaderTitle );
th.repaint();
}
但TableColumnModel
只能通过列索引引用。如何按列名获取TableColumn
?