From 455090e10a1ae0890f0a6b93eeb5f8018db08b1c Mon Sep 17 00:00:00 2001 From: Mikael Capelle Date: Mon, 16 Apr 2018 14:16:46 +0200 Subject: [PATCH] Fix issue with SolutionPanel and Java 9. --- src/main/org/insa/graphics/SolutionPanel.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/org/insa/graphics/SolutionPanel.java b/src/main/org/insa/graphics/SolutionPanel.java index 7384e3c..2d81569 100644 --- a/src/main/org/insa/graphics/SolutionPanel.java +++ b/src/main/org/insa/graphics/SolutionPanel.java @@ -122,7 +122,6 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap /* * (non-Javadoc) - * * @see java.lang.Object#toString() */ public String toString() { @@ -192,25 +191,24 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap solutionSelect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - SolutionBundle bundle = (SolutionBundle) solutionSelect.getSelectedItem(); - - // Handle case when the JComboBox is empty. - if (bundle == null) { - return; - } - if (currentBundle != null) { for (PathOverlay overlay: currentBundle.getOverlays()) { overlay.setVisible(false); } } - updateInformationLabel(bundle); - buttonPanel.setVisible(bundle.getSolution().isFeasible() && bundle.hasOverlays()); - clearButton.setText(bundle.getSolution().isFeasible() ? "Hide" : "Show"); + SolutionBundle bundle = (SolutionBundle) solutionSelect.getSelectedItem(); - for (PathOverlay overlay: bundle.getOverlays()) { - overlay.setVisible(true); + if (bundle != null) { + + updateInformationLabel(bundle); + buttonPanel + .setVisible(bundle.getSolution().isFeasible() && bundle.hasOverlays()); + clearButton.setText(bundle.getSolution().isFeasible() ? "Hide" : "Show"); + + for (PathOverlay overlay: bundle.getOverlays()) { + overlay.setVisible(true); + } } currentBundle = bundle; @@ -249,7 +247,7 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap if (enabled) { // Trigger event - solutionSelect.actionPerformed(null); + solutionSelect.setSelectedItem(currentBundle); } else { SolutionBundle bundle = (SolutionBundle) this.solutionSelect.getSelectedItem();