Example usage for javafx.scene.control.cell ComboBoxListCell forListView

List of usage examples for javafx.scene.control.cell ComboBoxListCell forListView

Introduction

In this page you can find the example usage for javafx.scene.control.cell ComboBoxListCell forListView.

Prototype

public static <T> Callback<ListView<T>, ListCell<T>> forListView(final ObservableList<T> items) 

Source Link

Document

Creates a ComboBox cell factory for use in ListView controls.

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    ObservableList<String> names = FXCollections.observableArrayList();
    ObservableList<String> data = FXCollections.observableArrayList();

    ListView<String> listView = new ListView<String>(data);
    listView.setPrefSize(200, 250);/*from   w w  w . j a v a  2s . co m*/
    listView.setEditable(true);

    names.addAll("A", "B", "C", "D", "E");

    data.add("Double Click to Select Value");

    listView.setItems(data);
    listView.setCellFactory(ComboBoxListCell.forListView(names));

    StackPane root = new StackPane();
    root.getChildren().add(listView);
    primaryStage.setScene(new Scene(root, 200, 250));
    primaryStage.show();
}