From fb75481e190d4f789e7ac6d062560b823b267adc Mon Sep 17 00:00:00 2001 From: kruland2607 Date: Tue, 31 Jul 2012 18:03:52 +0000 Subject: [PATCH] Fix refresh bug which sometimes happens when the plot configuration is changed. Sometimes after changing the configuration drop down (at the top), the y series combo boxes disappeared. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@945 180e2498-e6e9-4542-8430-84ac67f01cd8 --- .../sf/openrocket/gui/plot/SimulationPlotPanel.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/net/sf/openrocket/gui/plot/SimulationPlotPanel.java b/core/src/net/sf/openrocket/gui/plot/SimulationPlotPanel.java index 06544f52..515ad0c8 100644 --- a/core/src/net/sf/openrocket/gui/plot/SimulationPlotPanel.java +++ b/core/src/net/sf/openrocket/gui/plot/SimulationPlotPanel.java @@ -119,8 +119,16 @@ public class SimulationPlotPanel extends JPanel { } configurationSelector.addItemListener(new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { + // We are only concerned with ItemEvent.SELECTED to update + // the UI when the selected item changes. + // TODO - this should probably be implemented as an ActionListener instead + // of ItemStateListener. + if ( e.getStateChange() == ItemEvent.DESELECTED) { + return; + } if (modifying > 0) return; PlotConfiguration conf = (PlotConfiguration) configurationSelector.getSelectedItem(); @@ -357,7 +365,9 @@ public class SimulationPlotPanel extends JPanel { typeSelectorPanel.add(new PlotTypeSelector(i, type, unit, axis), "wrap"); } - typeSelectorPanel.repaint(); + // In order to consistantly update the ui, we need to validate before repaint. + typeSelectorPanel.validate(); + typeSelectorPanel.repaint(); eventTableModel.fireTableDataChanged(); } -- 2.30.2