Now saves when the Application is closed

Practice list persists
This commit is contained in:
law39 2020-05-01 13:33:07 +01:00
parent e95a8a9159
commit 74540757b7

View file

@ -6,6 +6,7 @@
*/
package uk.ac.aber.cs221.group20.javafx;
import javafx.application.Platform;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import uk.ac.aber.cs221.group20.json.DictionaryEntry;
@ -96,6 +97,14 @@ public class Application extends javafx.application.Application {
practiceList.add(entry);
}
}
//When the user closes the application, it will automatically write the dictionary to a json file.
stage.setOnCloseRequest(e -> {
jsonProcessing.writeOutJson(jsonFileFinalLocation.getAbsolutePath(), Application.dictionary);
Platform.exit();
System.exit(0);
});
new ScreenSwitch(stage); // Initialise the ScreenSwitch class, passing the programs Stage as the parameter in order to display the first screen.
}
}