]> Git Server - tankstelle.git/commitdiff
Bug bei Liste gefixt
authorSergej Pavlenko <sergepav0@gmail.com>
Thu, 20 Nov 2025 00:37:08 +0000 (01:37 +0100)
committerSergej Pavlenko <sergepav0@gmail.com>
Thu, 20 Nov 2025 00:37:08 +0000 (01:37 +0100)
src/main/java/de/diejungsvondertanke/tankstelle/FuelStationUI.java

index a64f934ac7a07f250c4170699f8c26fb7016e6c1..553c7905f6fac92dc6f7892c0140db1a73a86322 100644 (file)
@@ -358,17 +358,6 @@ public class FuelStationUI extends JFrame {
         throw new NoSuchFuelTypeError("This fuel station does not offer the fuel type " + type);
     }
 
-    /**
-     * Updates the selection of fuel stations for the ComboBox
-     *
-     * @author Sergej Pavlenko
-     */
-    private void updateStations() {
-        String[] names = buildStationNames();
-        DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(names);
-        comboFuelStations.setModel(model);
-    }
-
     /**
      * Create Panel for searching for a fuel station with a specific fuel type
      *
@@ -437,7 +426,7 @@ public class FuelStationUI extends JFrame {
                     Main.addNewFuelStation(supermarketCompany);
                     appendOutput("Fuel station with supermarket-company" + supermarketCompany +  " has been added.");
                 }
-                updateStations();
+                refreshStationNames();
                 txtAtrributes.setText("");
             } catch (NumberFormatException ex) {
                 showError("Please enter a valid number (for small / medium).");
@@ -479,20 +468,16 @@ public class FuelStationUI extends JFrame {
     }
 
     /**
-     * Refreshes ComboBox and List together
+     * Updates the selection of fuel stations for ComboBox and List
      *
      * @author Sergej Pavlenko
      */
     private void refreshStationNames() {
         String[] names = buildStationNames();
 
-        if (comboFuelStations != null) {
-            comboFuelStations.setModel(new DefaultComboBoxModel<>(names));
-        }
+        comboFuelStations.setModel(new DefaultComboBoxModel<>(names));
 
-        if (listFuelStations != null) {
-            listFuelStations.setListData(names);
-        }
+        listFuelStations.setListData(names);
     }
 
     private String getDisplayName(FuelStation station) {