From a47e2f416ee37ee5ead36439d03d275c01b4b3bb Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sun, 24 Sep 2023 22:11:52 +0200 Subject: [PATCH] Fix sim table not taking proper spotlight --- .../openrocket/gui/main/SimulationPanel.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java index 36f87e2da..78827fdea 100644 --- a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java @@ -1404,21 +1404,26 @@ public class SimulationPanel extends JPanel { * Focus on the simulation table and maintain the previous row selection(s). */ public void takeTheSpotlight() { - simulationTable.requestFocusInWindow(); - if (simulationTable.getRowCount() == 0 || simulationTable.getSelectedRows().length > 0) { - return; - } - if (previousSelection == null || previousSelection.length == 0) { - simulationTable.getSelectionModel().setSelectionInterval(0, 0); - } else { - simulationTable.clearSelection(); - for (int row : previousSelection) { - if (row < 0 || row >= simulationTable.getRowCount()) { - continue; + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + simulationTable.requestFocusInWindow(); + if (simulationTable.getRowCount() == 0 || simulationTable.getSelectedRows().length > 0) { + return; } - simulationTable.addRowSelectionInterval(row, row); + if (previousSelection == null || previousSelection.length == 0) { + simulationTable.getSelectionModel().setSelectionInterval(0, 0); + } else { + simulationTable.clearSelection(); + for (int row : previousSelection) { + if (row < 0 || row >= simulationTable.getRowCount()) { + continue; + } + simulationTable.addRowSelectionInterval(row, row); + } + } + updateActions(); } - } - updateActions(); + }); } }