From 60d036c71847e9cf6e1792c24ecb6c5f8ec9f8e7 Mon Sep 17 00:00:00 2001 From: Kristian Rekstad Date: Wed, 11 Nov 2020 01:49:54 +0100 Subject: [PATCH] Fix generate being disabled when navigating back --- .../ImageSelectionController.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/GifCreator/src/main/java/com/polarbirds/gifcreator/image_selection/ImageSelectionController.java b/GifCreator/src/main/java/com/polarbirds/gifcreator/image_selection/ImageSelectionController.java index 0854597..ae3555f 100644 --- a/GifCreator/src/main/java/com/polarbirds/gifcreator/image_selection/ImageSelectionController.java +++ b/GifCreator/src/main/java/com/polarbirds/gifcreator/image_selection/ImageSelectionController.java @@ -74,8 +74,11 @@ public void initialize(URL location, ResourceBundle resources) { leftList.setCellFactory(fileListView -> new FileNameCell()); - this.fileListChangeListener = change -> this.toggleGenerateButton(); - fm.getSelectedFilesList().addListener(fileListChangeListener); + this.fileListChangeListener = change -> { + btnGenerate.setDisable(change.getList().isEmpty()); + }; + fm.getSelectedFilesList().addListener(this.fileListChangeListener); + btnGenerate.setDisable(fm.getSelectedFilesList().isEmpty()); } @Override @@ -206,15 +209,6 @@ public void nextMode(Event e) { //UTILITY - - public void toggleGenerateButton() { - if (rightList.getItems().size() == 0) { - btnGenerate.setDisable(true); - } else { - btnGenerate.setDisable(false); - } - } - /** * Loads strings from resources and saves it to private strings. * If a value can't be loaded from resources, the private string keeps the default value.