From 4e541e67cf9aa173ecd774fa0f07f6b9e60a30db Mon Sep 17 00:00:00 2001 From: Mikael Capelle Date: Wed, 28 Mar 2018 17:39:00 +0200 Subject: [PATCH] Fix issue with graph progress bar. --- .../org/insa/graphics/GraphReaderProgressBar.java | 3 ++- src/main/org/insa/graphics/MainWindow.java | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/org/insa/graphics/GraphReaderProgressBar.java b/src/main/org/insa/graphics/GraphReaderProgressBar.java index 98f424f..da223cf 100644 --- a/src/main/org/insa/graphics/GraphReaderProgressBar.java +++ b/src/main/org/insa/graphics/GraphReaderProgressBar.java @@ -37,7 +37,7 @@ public class GraphReaderProgressBar extends JDialog implements GraphReaderObserv private final JProgressBar[] progressBars = new JProgressBar[3]; // Current element read, and modulo. - private int[] counters = new int[] { 0, 0, 0 }; + private int[] counters = new int[]{ 0, 0, 0 }; private int[] modulos = new int[3]; public GraphReaderProgressBar(JFrame owner) { @@ -75,6 +75,7 @@ public class GraphReaderProgressBar extends JDialog implements GraphReaderObserv @Override public void notifyEndReading() { setVisible(false); + dispose(); } protected void initProgressBar(int index, int max) { diff --git a/src/main/org/insa/graphics/MainWindow.java b/src/main/org/insa/graphics/MainWindow.java index 252b197..8eb2eda 100644 --- a/src/main/org/insa/graphics/MainWindow.java +++ b/src/main/org/insa/graphics/MainWindow.java @@ -157,7 +157,7 @@ public class MainWindow extends JFrame { this.currentPalette = this.basicPalette; wccPanel = new AlgorithmPanel(this, WeaklyConnectedComponentsAlgorithm.class, - "Weakly-Connected Components", new String[] {}, false); + "Weakly-Connected Components", new String[]{}, false); wccPanel.addStartActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -202,7 +202,7 @@ public class MainWindow extends JFrame { }); spPanel = new AlgorithmPanel(this, ShortestPathAlgorithm.class, "Shortest-Path", - new String[] { "Origin", "Destination" }, true); + new String[]{ "Origin", "Destination" }, true); spPanel.addStartActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -254,13 +254,12 @@ public class MainWindow extends JFrame { } }); - cpPanel = new AlgorithmPanel( - this, CarPoolingAlgorithm.class, "Car-Pooling", new String[] { "Origin Car", - "Origin Pedestrian", "Destination Car", "Destination Pedestrian" }, + cpPanel = new AlgorithmPanel(this, CarPoolingAlgorithm.class, "Car-Pooling", new String[]{ + "Origin Car", "Origin Pedestrian", "Destination Car", "Destination Pedestrian" }, true); psPanel = new AlgorithmPanel(this, PackageSwitchAlgorithm.class, "Car-Pooling", - new String[] { "Oribin A", "Origin B", "Destination A", "Destination B" }, true); + new String[]{ "Oribin A", "Origin B", "Destination A", "Destination B" }, true); // add algorithm panels algoPanels.add(wccPanel); @@ -580,10 +579,10 @@ public class MainWindow extends JFrame { reader.addObserver(progressBar); try { graph = reader.read(); - System.out.flush(); } catch (Exception exception) { progressBar.setVisible(false); + progressBar.dispose(); progressBar = null; JOptionPane.showMessageDialog(MainWindow.this, "Unable to read graph from the selected file."); @@ -593,6 +592,7 @@ public class MainWindow extends JFrame { // In case of.... progressBar.setVisible(false); + progressBar.dispose(); progressBar = null; String info = graph.getMapId();