From b88b789a091f50c99fefeee4675ba703c04db0cc Mon Sep 17 00:00:00 2001 From: SiboVG Date: Thu, 28 Sep 2023 21:52:59 +0200 Subject: [PATCH] Ensure column index does not exceed table size --- swing/src/net/sf/openrocket/gui/util/GUIUtil.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swing/src/net/sf/openrocket/gui/util/GUIUtil.java b/swing/src/net/sf/openrocket/gui/util/GUIUtil.java index e11f5fe81..2becea7c8 100644 --- a/swing/src/net/sf/openrocket/gui/util/GUIUtil.java +++ b/swing/src/net/sf/openrocket/gui/util/GUIUtil.java @@ -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);