diff --git a/.idea/workspace.xml b/.idea/workspace.xml index db626bd2..04333826 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,15 +7,7 @@ - - - - - - - - @@ -78,8 +70,8 @@ - - + + @@ -1058,12 +1050,18 @@ file://$PROJECT_DIR$/src/Main.java - 164 + 165 + + file://$PROJECT_DIR$/src/Main.java + 135 + + - - - + + diff --git a/src/Main.java b/src/Main.java index 2c250c27..56915ef1 100644 --- a/src/Main.java +++ b/src/Main.java @@ -112,14 +112,16 @@ public void start(Stage primaryStage) throws Exception{ primaryStage.setMaximized(true); + //====== SAVING/LOADING APP STATE =====// + // Install event handler for when the app is closed primaryStage.setOnCloseRequest((windowEvent) -> { - this.saveCalculatorState(); + //this.saveCalculatorState(); } ); // Load saved calculator state (if any) - loadCalculatorState(); + //loadCalculatorState(); // Show the NinjaCalc app primaryStage.show(); @@ -131,19 +133,18 @@ private void saveCalculatorState() { try { // Write to disk with FileOutputStream - FileOutputStream f_out = new + FileOutputStream fileOS = new FileOutputStream(appStateFileName); // Write object with ObjectOutputStream - ObjectOutputStream obj_out = new - ObjectOutputStream(f_out); + ObjectOutputStream objOS = new + ObjectOutputStream(fileOS); // Write object out to disk - obj_out.writeObject(controller.getOpenCalculators()); - - obj_out.close(); + objOS.writeObject(controller.getOpenCalculators()); - f_out.close(); + objOS.close(); + fileOS.close(); } catch (FileNotFoundException e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("FileNotFoundException");