Fix issue with SolutionPanel and Java 9.

This commit is contained in:
Mikael Capelle 2018-04-16 14:16:46 +02:00
parent aea8f054d5
commit 455090e10a

View File

@ -122,7 +122,6 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
/* /*
* (non-Javadoc) * (non-Javadoc)
*
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
public String toString() { public String toString() {
@ -192,25 +191,24 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
solutionSelect.addActionListener(new ActionListener() { solutionSelect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
SolutionBundle bundle = (SolutionBundle) solutionSelect.getSelectedItem();
// Handle case when the JComboBox is empty.
if (bundle == null) {
return;
}
if (currentBundle != null) { if (currentBundle != null) {
for (PathOverlay overlay: currentBundle.getOverlays()) { for (PathOverlay overlay: currentBundle.getOverlays()) {
overlay.setVisible(false); overlay.setVisible(false);
} }
} }
updateInformationLabel(bundle); SolutionBundle bundle = (SolutionBundle) solutionSelect.getSelectedItem();
buttonPanel.setVisible(bundle.getSolution().isFeasible() && bundle.hasOverlays());
clearButton.setText(bundle.getSolution().isFeasible() ? "Hide" : "Show");
for (PathOverlay overlay: bundle.getOverlays()) { if (bundle != null) {
overlay.setVisible(true);
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; currentBundle = bundle;
@ -249,7 +247,7 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
if (enabled) { if (enabled) {
// Trigger event // Trigger event
solutionSelect.actionPerformed(null); solutionSelect.setSelectedItem(currentBundle);
} }
else { else {
SolutionBundle bundle = (SolutionBundle) this.solutionSelect.getSelectedItem(); SolutionBundle bundle = (SolutionBundle) this.solutionSelect.getSelectedItem();