From c6cb2aae4cba8f30c3f0bd874fb1863426c3f5dc Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sun, 29 May 2022 11:39:18 +0200 Subject: [PATCH] [#1286] Use table row selection listener to update sim button state --- .../net/sf/openrocket/gui/main/SimulationPanel.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java index 74c2b30e8..05c7b04ff 100644 --- a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java @@ -35,6 +35,8 @@ import javax.swing.JTable; import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.text.DefaultEditorKit; @@ -565,8 +567,16 @@ public class SimulationPanel extends JPanel { } } else if (e.getButton() == MouseEvent.BUTTON3 && e.getClickCount() == 1){ doPopup(e); - } else { + } + } + }); + + simulationTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + private int previousRow = -1; + public void valueChanged(ListSelectionEvent event) { + if (simulationTable.getSelectedRow() != previousRow) { updateButtonStates(); + previousRow = simulationTable.getSelectedRow(); } } });