Example usage for javafx.scene.control ListView setMaxWidth

List of usage examples for javafx.scene.control ListView setMaxWidth

Introduction

In this page you can find the example usage for javafx.scene.control ListView setMaxWidth.

Prototype

public final void setMaxWidth(double value) 

Source Link

Usage

From source file:Main.java

private ListView<Person> createLeaderListView(ObservableList<Person> leaders) {
    final ListView<Person> leaderListView = new ListView<>(leaders);
    leaderListView.setPrefWidth(150);//from w  w w  .j  a v  a2  s  .  c om
    leaderListView.setMaxWidth(Double.MAX_VALUE);
    leaderListView.setPrefHeight(150);

    leaderListView.setCellFactory(new Callback<ListView<Person>, ListCell<Person>>() {
        @Override
        public ListCell<Person> call(ListView<Person> param) {
            Tooltip tooltip = new Tooltip();

            ListCell<Person> cell = new ListCell<Person>() {
                @Override
                public void updateItem(Person item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        // leadLbl.setText(item.getAliasName());
                        setText(item.getFirstName() + " " + item.getLastName());
                        tooltip.setText(item.getAliasName());
                        setTooltip(tooltip);
                    }
                }
            };
            return cell;
        }
    });

    return leaderListView;
}