Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Latest commit

 

History

History
32 lines (24 loc) · 1.02 KB

README.md

File metadata and controls

32 lines (24 loc) · 1.02 KB

AutoFillCombobox

An simple autofill approach to extend the default JavaFX's combobox behavior.

Motivation

The default combobox component of JavaFX dont offer a option to query his list of items. This code is a powerful solution to this problem.

Assumptions

  • You has an ordered list of strings

Performance tips

  • For type safe reasons we use .toLowerCase() function at input string and on search. If your list contains only upper/lower case strings you can remove the .toLowerCase() from search.

    items.stream().filter(p -> p.toLowerCase().startsWith(lower)).findFirst();

Code Example

With a predefined list:

  ObservableList<String> items = FXCollections.observableArrayList();
  // Add items to list
  AutoFillComboBox autoFill = new AutoFillComboBox(items);

Without a predefined list of items:

  AutoFillComboBox autoFill = new AutoFillComboBox();
  // some code
  ObservableList<String> items = FXCollections.observableArrayList();
  autoFill.setItems(items);
  autoFill.setAutoFill(true);