From 687fb6f6e39db3755667374839b2200cd5ca15bc Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sat, 30 Jul 2022 00:51:51 +0200 Subject: [PATCH] Fix sim table keep selection after tab switch --- .../net/sf/openrocket/gui/main/SimulationPanel.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java index 6a72f8982..e219d6146 100644 --- a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java @@ -998,8 +998,14 @@ public class SimulationPanel extends JPanel { */ public void takeTheSpotlight() { simulationTable.requestFocusInWindow(); - if (simulationTable.getSelectedRowCount() == 0 && simulationTable.getRowCount() > 0) { - simulationTable.setRowSelectionInterval(0, 0); + int selection = simulationTable.getSelectionModel().getAnchorSelectionIndex(); + if (selection == -1) { + if (simulationTable.getRowCount() > 0) { + selection = 0; + } else { + return; + } } + simulationTable.setRowSelectionInterval(selection, selection); } }