diff --git a/src/main/java/org/cryptomator/ui/addvaultwizard/CreateNewVaultLocationController.java b/src/main/java/org/cryptomator/ui/addvaultwizard/CreateNewVaultLocationController.java index dcd6ce72d..914bb243e 100644 --- a/src/main/java/org/cryptomator/ui/addvaultwizard/CreateNewVaultLocationController.java +++ b/src/main/java/org/cryptomator/ui/addvaultwizard/CreateNewVaultLocationController.java @@ -148,6 +148,8 @@ public class CreateNewVaultLocationController implements FxController { } private void createRadioButtonFor(LocationPreset preset) { + assert !radioButtonVBox.getChildren().isEmpty(); + Platform.runLater(() -> { var btn = new RadioButton(preset.name()); btn.setUserData(preset.path()); @@ -155,9 +157,7 @@ public class CreateNewVaultLocationController implements FxController { //in place sorting var vboxElements = radioButtonVBox.getChildren(); boolean added = false; - int listIndex = 0; //first item of vbox is the list header - while (listIndex < vboxElements.size()) { - listIndex++; + for (int listIndex = 0; listIndex < vboxElements.size(); listIndex++) { if (vboxElements.get(listIndex) instanceof RadioButton rb) { //another radio button if (rb.getText().compareTo(preset.name()) > 0) { @@ -165,13 +165,11 @@ public class CreateNewVaultLocationController implements FxController { added = true; break; } - } else { - //end of all radiobuttons - break; } } + if (!added) { - vboxElements.add(listIndex, btn); + vboxElements.add(vboxElements.size() - 1, btn); //last element is always the custom location btn } locationPresetsToggler.getToggles().add(btn); diff --git a/src/main/resources/fxml/addvault_new_location.fxml b/src/main/resources/fxml/addvault_new_location.fxml index 8310ef1fd..bbea7e3cc 100644 --- a/src/main/resources/fxml/addvault_new_location.fxml +++ b/src/main/resources/fxml/addvault_new_location.fxml @@ -1,18 +1,18 @@ + + - - - - +