Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已宣布我JTable为:
JTable
data_table = new JTable(info, header) { @Override public boolean isCellEditable(int row, int column) { return false; } };
但我已经看到在运行时可以用鼠标拖动列。我怎样才能禁用它?
data_table.getTableHeader().setReorderingAllowed(false);应该做这项工作,除非您的意思是用户可以调整列标题的大小。
data_table.getTableHeader().setReorderingAllowed(false);
对于使用Netbeans IDE 遇到此问题的任何人,您可以通过执行以下步骤来禁止用户拖动 JTable 中的列。