Do not ask to close if finished
This commit is contained in:
@@ -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,17 +48,19 @@ 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 (JOptionPane.showConfirmDialog(frame, "Abort and Close?") == 0) {
|
if (!finished) {
|
||||||
aborted = true;
|
if (JOptionPane.showConfirmDialog(frame, "Abort and Close?") == 0) {
|
||||||
if (processingThread != null) {
|
aborted = true;
|
||||||
try {
|
if (processingThread != null) {
|
||||||
processingThread.join();
|
try {
|
||||||
} catch (InterruptedException e1) {
|
processingThread.join();
|
||||||
e1.printStackTrace();
|
} catch (InterruptedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
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!");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user