diff options
author | Artur <artur@vaadin.com> | 2017-04-26 11:12:01 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-04-26 11:12:01 +0300 |
commit | a48e5a1cb8f6c8ae18af19406d3e7ba3c9886c69 (patch) | |
tree | 9965868a6606c4ab56f9ec55b8e9090eefcef9f9 /server/src | |
parent | 2e5b49113439310d2dae9ec86fca3ccdf74833f5 (diff) | |
download | vaadin-framework-a48e5a1cb8f6c8ae18af19406d3e7ba3c9886c69.tar.gz vaadin-framework-a48e5a1cb8f6c8ae18af19406d3e7ba3c9886c69.zip |
Add an option for defining number of visible items in a NativeSelect (#9109)
Diffstat (limited to 'server/src')
-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; + } } |