JTable,禁用用户列拖动
问题描述:
我已将我的JTable
声明为:
data_table = new JTable(info, header) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
但是我已经看到,在运行时可以用鼠标拖动列. 如何禁用它?
But I've seen that at runtime it's possible to drag the columns with mouse. How can I disable that?
答
data_table.getTableHeader().setReorderingAllowed(false);
应该可以完成这项工作,除非您是说用户可以调整列标题的大小.
data_table.getTableHeader().setReorderingAllowed(false);
should do the job, unless you mean that the user can resize column headers.