diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicGridDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicGridDialog.java index 5fca71ae..d3253074 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MnemonicGridDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MnemonicGridDialog.java @@ -40,6 +40,8 @@ public class MnemonicGridDialog extends Dialog> { private final BooleanProperty initializedProperty = new SimpleBooleanProperty(false); private final BooleanProperty wordsSelectedProperty = new SimpleBooleanProperty(false); + private final List selectedCells = new ArrayList<>(); + public MnemonicGridDialog() { DialogPane dialogPane = new MnemonicGridDialogPane(); setDialogPane(dialogPane); @@ -71,6 +73,15 @@ public class MnemonicGridDialog extends Dialog> { spreadsheetView.getSelectionModel().getSelectedCells().addListener(new ListChangeListener<>() { @Override public void onChanged(Change c) { + while(c.next()) { + if(c.wasRemoved()) { + selectedCells.removeAll(c.getRemoved()); + } + if(c.wasAdded()) { + selectedCells.addAll(c.getAddedSubList()); + } + } + int numWords = c.getList().size(); wordsSelectedProperty.set(numWords == 11 || numWords == 23); } @@ -137,7 +148,7 @@ public class MnemonicGridDialog extends Dialog> { } private List getSelectedWords() { - List abbreviations = spreadsheetView.getSelectionModel().getSelectedCells().stream() + List abbreviations = selectedCells.stream() .map(position -> (String)spreadsheetView.getGrid().getRows().get(position.getRow()).get(position.getColumn()).getItem()).collect(Collectors.toList()); List words = new ArrayList<>();