Ensure column index does not exceed table size
This commit is contained in:
parent
382600f866
commit
b88b789a09
@ -435,6 +435,10 @@ public class GUIUtil {
|
||||
}
|
||||
|
||||
public static int getOptimalColumnWidth(JTable table, int columnIndex) {
|
||||
if (columnIndex >= table.getColumnModel().getColumnCount()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
TableColumn column = table.getColumnModel().getColumn(columnIndex);
|
||||
Component headerRenderer = table.getTableHeader().getDefaultRenderer()
|
||||
.getTableCellRendererComponent(table, column.getHeaderValue(), false, false, 0, columnIndex);
|
||||
|
Loading…
x
Reference in New Issue
Block a user