Search in sources :

Example 1 with ISuggestionRequest

use of org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest in project Gargoyle by callakrsos.

the class AutoCompletionTextBindingExam method start.

/* (non-Javadoc)
	 * @see javafx.application.Application#start(javafx.stage.Stage)
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    TextField textField = new TextField();
    List<String> asList = Arrays.asList("sssss", "aaaaa");
    AutoCompletionTextFieldBinding<String> autoCompletionTextFieldBinding = new AutoCompletionTextFieldBinding<>(textField, new Callback<ISuggestionRequest, Collection<String>>() {

        @Override
        public Collection<String> call(ISuggestionRequest param) {
            String userText = param.getUserText();
            return asList.stream().filter(v -> v.startsWith(userText)).collect(Collectors.toList());
        }
    });
    autoCompletionTextFieldBinding.setVisibleRowCount(10);
    primaryStage.setScene(new Scene(new BorderPane(textField)));
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) AutoCompletionTextFieldBinding(impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding) TextField(javafx.scene.control.TextField) Collection(java.util.Collection) ISuggestionRequest(org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest) Scene(javafx.scene.Scene)

Aggregations

AutoCompletionTextFieldBinding (impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding)1 Collection (java.util.Collection)1 Scene (javafx.scene.Scene)1 TextField (javafx.scene.control.TextField)1 BorderPane (javafx.scene.layout.BorderPane)1 ISuggestionRequest (org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest)1