diff --git a/src/main/java/name/nathanmcrae/numbersstation/StationSelectionController.java b/src/main/java/name/nathanmcrae/numbersstation/StationSelectionController.java index 84146a6..7669ef1 100644 --- a/src/main/java/name/nathanmcrae/numbersstation/StationSelectionController.java +++ b/src/main/java/name/nathanmcrae/numbersstation/StationSelectionController.java @@ -1,5 +1,6 @@ package name.nathanmcrae.numbersstation; +import java.util.Optional; import javafx.collections.ListChangeListener; import javafx.collections.FXCollections; import javafx.collections.ObservableList; @@ -11,7 +12,6 @@ import javafx.event.ActionEvent; import javafx.event.Event; import javafx.scene.Node; import javafx.stage.Stage; -import java.util.Optional; public class StationSelectionController { @@ -23,9 +23,7 @@ public class StationSelectionController { private ObservableList stationList; public StationSelectionController() { - // Initialize the list with an empty list stationList = FXCollections.observableArrayList(); - // Add listener to the stationList stationList.addListener((ListChangeListener) change -> onStationListChanged(change)); } @@ -53,16 +51,13 @@ public class StationSelectionController { @FXML private void handleAddButtonPress(ActionEvent event) { - // Create a TextInputDialog TextInputDialog dialog = new TextInputDialog(); dialog.setTitle("New Station"); dialog.setHeaderText("Add a New Station"); dialog.setContentText("Please enter the station name:"); - // Show the dialog and capture the result Optional result = dialog.showAndWait(); result.ifPresent(stationName -> { - // Add the new station to the list StationSettings newStation = new StationSettings(stationName); stationList.add(newStation); }); @@ -70,7 +65,6 @@ public class StationSelectionController { @FXML private void handleRemoveButtonPress(ActionEvent event) { - // Remove the selected item from the list int selectedIndex = stationListView.getSelectionModel().getSelectedIndex(); if (selectedIndex >= 0) { stationList.remove(selectedIndex);