diff --git a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java @@ -137,6 +137,7 @@ registerChangeListener(comboBox.itemsProperty(), "ITEMS"); registerChangeListener(comboBox.promptTextProperty(), "PROMPT_TEXT"); registerChangeListener(comboBox.cellFactoryProperty(), "CELL_FACTORY"); + registerChangeListener(comboBox.visibleRowCountProperty(), "VISIBLE_ROW_COUNT"); } public void updateListViewItems() { @@ -175,6 +176,9 @@ updateDisplayNode(); } else if ("CELL_FACTORY".equals(p)) { updateCellFactory(); + } else if ("VISIBLE_ROW_COUNT".equals(p)) { + if (listView == null) return; + listView.setPrefHeight(getListViewPrefHeight()); } } @@ -326,17 +330,7 @@ @Override protected double computePrefHeight(double width) { doCSSCheck(); - double ph; - if (getSkin() instanceof VirtualContainerBase) { - int maxRows = comboBox.getVisibleRowCount(); - VirtualContainerBase skin = (VirtualContainerBase)getSkin(); - ph = skin.getVirtualFlowPreferredHeight(maxRows); - } else { - double ch = comboBox.getItems().size() * 25; - ph = Math.min(ch, 200); - } - - return ph; + return getListViewPrefHeight(); } private void doCSSCheck() { @@ -403,6 +397,19 @@ return 50; } + private double getListViewPrefHeight() { + double ph; + if (listView.getSkin() instanceof VirtualContainerBase) { + int maxRows = comboBox.getVisibleRowCount(); + VirtualContainerBase skin = (VirtualContainerBase)listView.getSkin(); + ph = skin.getVirtualFlowPreferredHeight(maxRows); + } else { + double ch = comboBox.getItems().size() * 25; + ph = Math.min(ch, 200); + } + + return ph; + } /************************************************************************** *