From 3e82a2b5481aff31c063ba9ed2952b32c5784388 Mon Sep 17 00:00:00 2001 From: Anastasia Smirnova Date: Tue, 8 May 2018 15:13:09 +0300 Subject: Update combobox docs to use setNewItemProvider (#10901) --- documentation/components/components-combobox.asciidoc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'documentation') diff --git a/documentation/components/components-combobox.asciidoc b/documentation/components/components-combobox.asciidoc index 7f7640a079..c7a1fefba8 100644 --- a/documentation/components/components-combobox.asciidoc +++ b/documentation/components/components-combobox.asciidoc @@ -52,7 +52,7 @@ attempt to do so may result in an exception. === Handling New Items -Adding new items is handled by a [interfacename]#NewItemHandler#, which gets the +Adding new items is handled by a [interfacename]#NewItemProvider#, which gets the item caption string as parameter for the [methodname]#accept(String)# method. @@ -73,7 +73,7 @@ select.setItemCaptionGenerator(Planet::getName); // Allow adding new items and add // handling for new items -select.setNewItemHandler(inputString -> { +select.setNewItemProvider(inputString -> { Planet newPlanet = new Planet(planets.size(), inputString); planets.add(newPlanet); @@ -81,8 +81,7 @@ select.setNewItemHandler(inputString -> { // Update combobox content select.setItems(planets); - // Remember to set the selection to the new item - select.setSelectedItem(newPlanet); + return Optional.of(newPlanet); }); ---- -- cgit v1.2.3