suggestionList.prefWidthProperty().bind(control.prefWidthProperty()); suggestionList.maxWidthProperty().bind(control.maxWidthProperty()); suggestionList.minWidthProperty().bind(control.minWidthProperty()); registerEventListener();
public AutoCompletePopupSkin(AutoCompletePopup<T> control){ this.control = control; suggestionList = new ListView<>(control.getSuggestions()); suggestionList.getStyleClass().add(AutoCompletePopup.DEFAULT_STYLE_CLASS); suggestionList.getStylesheets().add(AutoCompletionBinding.class .getResource("autocompletion.css").toExternalForm()); //$NON-NLS-1$ /** * Here we bind the prefHeightProperty to the minimum height between the * max visible rows and the current items list. We also add an arbitrary * 5 number because when we have only one item we have the vertical * scrollBar showing for no reason. */ suggestionList.prefHeightProperty().bind( Bindings.min(control.visibleRowCountProperty(), Bindings.size(suggestionList.getItems())) .multiply(LIST_CELL_HEIGHT).add(18)); suggestionList.setCellFactory(TextFieldListCell.forListView(control.getConverter())); //Allowing the user to control ListView width. suggestionList.prefWidthProperty().bind(control.prefWidthProperty()); suggestionList.maxWidthProperty().bind(control.maxWidthProperty()); suggestionList.minWidthProperty().bind(control.minWidthProperty()); registerEventListener(); }
@SuppressWarnings("unchecked") public VLAutoCompletePopupSkin(VLAutocomplete control) { this.control = control; suggestionList = control.getListPopup(); control.getListView().getStylesheets().add(AutoCompletionBinding.class.getResource("autocompletion.css").toExternalForm()); //$NON-NLS-1$ control.getListView().getStylesheets().add(AutoCompletionBinding.class.getResource("autocompletion.css").toExternalForm()); //$NON-NLS-1$ /** * Here we bind the prefHeightProperty to the minimum height between the max visible rows and the * current items list. We also add an arbitrary 5 number because when we have only one item we have * the vertical scrollBar showing for no reason. */ suggestionList.prefHeightProperty().bind(Bindings.min(control.visibleRowCountProperty(), Bindings.size(control.getListView().getItems())).multiply(LIST_CELL_HEIGHT).add(18)); // Allowing the user to control ListView width. suggestionList.prefWidthProperty().bind(control.widthProperty()); suggestionList.maxWidthProperty().bind(control.maxWidthProperty()); suggestionList.minWidthProperty().bind(control.minWidthProperty()); control.getListView().prefWidthProperty().bind(control.widthProperty()); control.getListView().maxWidthProperty().bind(control.maxWidthProperty()); control.getListView().minWidthProperty().bind(control.minWidthProperty()); }
suggestionList.prefWidthProperty().bind(control.prefWidthProperty()); suggestionList.maxWidthProperty().bind(control.maxWidthProperty()); suggestionList.minWidthProperty().bind(control.minWidthProperty()); registerEventListener();