Do not ask to close if finished

This commit is contained in:
Lucas Alber
2019-02-27 15:39:29 +01:00
parent 12900e664f
commit 60f95bd734

View File

@@ -19,6 +19,7 @@ public class Main {
private static Thread processingThread; private static Thread processingThread;
private static boolean aborted; private static boolean aborted;
private static boolean finished;
/** /**
* Main entry point to application. * Main entry point to application.
@@ -47,6 +48,7 @@ public class Main {
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowAdapter(){ frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
if (!finished) {
if (JOptionPane.showConfirmDialog(frame, "Abort and Close?") == 0) { if (JOptionPane.showConfirmDialog(frame, "Abort and Close?") == 0) {
aborted = true; aborted = true;
if (processingThread != null) { if (processingThread != null) {
@@ -58,6 +60,7 @@ public class Main {
} }
System.exit(0); System.exit(0);
} }
} else System.exit(0);
} }
}); });
@@ -84,6 +87,7 @@ public class Main {
e.printStackTrace(); e.printStackTrace();
} }
finished = true;
textArea.append("FINISHED!"); textArea.append("FINISHED!");
}); });