ArrayList<String> aniNames = new ArrayList<>();
I made connection with Database and stored 7K anime names in above ArrayList.
JFXAutoCompletePopup<String> autoCompPop = new JFXAutoCompletePopup<>();
for (int i=0; i<aniNames.size(); i++){
autoCompPop.getSuggestions().addAll(aniNames.get(i));
}
autoCompPop.setSelectionHandler(event ->{
autoTF.setText(event.getObject());
});
autoTF.textProperty().addListener(observable -> {
autoCompPop.filter(string -> string.toLowerCase().contains(autoTF.getText().toLowerCase()));
if (autoCompPop.getFilteredSuggestions().isEmpty() || autoTF.getText().isEmpty()) {
autoCompPop.hide();
} else {
autoCompPop.show(autoTF);
}
});
So I wrote this program in which when I type something, it shows auto completion popup.
When I type a single letter, lets say "a" or any other, It shows almost all anime having "a" in there names, which means almost all 7k anime.
I want to limit the number of results it shows if exceeds a certain number, for example, if more than 20 anime have "a" in their name then I want it to show only first 20 anime in the popup.