diff options
Diffstat (limited to 'server/src/main/java/com/vaadin/ui/NativeSelect.java')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/NativeSelect.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/NativeSelect.java b/server/src/main/java/com/vaadin/ui/NativeSelect.java index 4d08aacd12..a0d5741262 100644 --- a/server/src/main/java/com/vaadin/ui/NativeSelect.java +++ b/server/src/main/java/com/vaadin/ui/NativeSelect.java @@ -203,4 +203,33 @@ public class NativeSelect<T> extends AbstractSingleSelect<T> Objects.nonNull(caption); getState().emptySelectionCaption = caption; } + + /** + * Sets the number of items that are visible. If only one item is visible, + * then the box will be displayed as a drop-down list (the default). + * + * @since + * @param visibleItemCount + * the visible item count + * @throws IllegalArgumentException + * if the value is smaller than one + */ + public void setVisibleItemCount(int visibleItemCount) { + if (visibleItemCount < 1) { + throw new IllegalArgumentException( + "There must be at least one item visible"); + } + getState().visibleItemCount = visibleItemCount; + } + + /** + * Gets the number of items that are visible. If only one item is visible, + * then the box will be displayed as a drop-down list. + * + * @since + * @return the visible item count + */ + public int getVisibleItemCount() { + return getState(false).visibleItemCount; + } } |