diff --git a/src/main/java/name/nathanmcrae/NumbersStationController.java b/src/main/java/name/nathanmcrae/NumbersStationController.java index 241e3f7..fd1b8d7 100644 --- a/src/main/java/name/nathanmcrae/NumbersStationController.java +++ b/src/main/java/name/nathanmcrae/NumbersStationController.java @@ -79,16 +79,18 @@ public class NumbersStationController implements Initializable { selectStationStage.setScene(new Scene(root)); selectStationStage.show(); selectStationStage.setOnHiding(event -> { - selectedStationName.set((String) selectStationStage.getUserData()); - if (selectedStation != null) { - selectedStation = settings.getStations().stream() - .filter(station -> station.getName().equals(selectedStationName.get())) - .findFirst() - .orElse(null); - } - settings.setSelectedStationName(selectedStationName.get()); + String newStationName = (String)selectStationStage.getUserData(); + StationSettings newSelectedStation = settings.getStations().stream() + .filter(station -> station.getName().equals(newStationName)) + .findFirst() + .orElse(null); + if (newSelectedStation != null) { + selectedStation = newSelectedStation; + selectedStationName.set(newStationName); + settings.setSelectedStationName(selectedStationName.get()); - settings.save(); + settings.save(); + } }); } catch (Exception e) { e.printStackTrace();