Skip to content

ComboBox

Selection control pairing a current selection button with a dropdown options list.

Overview

ComboBox allows selecting one item from a list of predefined options. When opened, an overlay popup displays the options with scroll support and hover highlighting.

Resolution Selector

ComboBox resolution = new ComboBox()
        .options("1920x1080", "2560x1440", "3840x2160")
        .selectedIndex(0);
resolution.onSelectionChanged(e -> applyResolution(resolution.selectedItem()));

API

ComboBox::addItem(String)

Add Item

Appends a single item option.

Parameter Type Description
item String —

Returns ComboBox.

ComboBox::close()

Close List

Closes popup dropdown options list.

Returns ComboBox.

ComboBox::itemCount()

Get Item Count

Returns total number of options.

Returns int.

ComboBox::items()

Get Items

Returns list of string options.

Returns List.

ComboBox::items(List)

Set Items

Sets selectable string options.

Parameter Type Description
items List —

Returns ComboBox.

ComboBox::open()

Open List

Opens popup dropdown options list.

Returns ComboBox.

ComboBox::opened()

Is Opened

Returns whether dropdown list is open.

Returns boolean.

ComboBox::optionHoverBackground(ColorView)

Hover Background

Sets option highlight background color when hovered.

Parameter Type Description
color ColorView —

Returns ComboBox.

ComboBox::removeItem(int)

Remove Item

Removes item option at given index.

Parameter Type Description
index int —

Returns ComboBox.

ComboBox::selectedIndex()

Get Selected Index

Returns zero-based index of selected item or -1.

Returns int.

ComboBox::selectedIndex(int)

Set Selected Index

Selects option at index and updates header.

Parameter Type Description
index int option index

Returns ComboBox.

ComboBox::selectedItem()

Get Selected Item

Returns text of selected option or empty string.

Returns String.

ComboBox::silentSelectedIndex(int)

Set Silent Selected Index

Updates selected option index without firing listeners.

Parameter Type Description
index int —

Returns ComboBox.

ComboBox::toggle()

Toggle List

Toggles popup dropdown open/closed state.

Returns ComboBox.