Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ComboBox

[108:7] extends: Control

ComboBox wraps the JavaFX ComboBox control, a drop-down selection widget that combines a button with a pop-up list of choices. Users can select one item from the list, and when the control is set to editable mode they can also type a custom value directly into the text field portion. The style class combo-box is applied by default, and the control inherits all CSS properties from ComboBoxBase and Control. The tables below list every CSS property available to ComboBox, organized by the class level where each property is defined. Properties defined at a higher level are inherited by all subclasses below it.

CSS Pseudo-classes -- ComboBox

Pseudo-class Description
editable Applies when the editable property is true, enabling direct text entry.
showing Applies when the pop-up list is currently visible.
armed Applies when the armed property is true (button pressed, pointer still over it).

CSS Properties -- Control

Property Values Default Description
-fx-skin <string> null Fully qualified class name of the Skin to use for rendering this control.
-fx-focus-traversable true | false true When true, the control participates in focus traversal via the keyboard Tab key.

CSS Properties -- Region

Background fills

Property Values Default Description
-fx-background-color <paint> [, <paint>]* transparent One or more paint values for background fill layers, rendered back to front.
-fx-background-insets <size> or <t> <r> <b> <l> [, ...]* 0 0 0 0 Insets from the region edges for each background fill layer.
-fx-background-radius <size> [/ <size>]* [, ...]* 0 0 0 0 Corner radii for each background fill layer.

Background images

Property Values Default Description
-fx-background-image <uri> [, <uri>]* null One or more image URIs for background image layers.
-fx-background-position <bg-position> [, ...]* 0% 0% Position of each background image within the region. Accepts keywords or size values.
-fx-background-repeat <repeat-style> [, ...]* repeat repeat Tiling behavior for each background image. Values: repeat, no-repeat, round, space applied per axis.
-fx-background-size <bg-size> [, ...]* auto auto Dimensions for each background image. Supports cover, contain, stretch, or explicit sizes.

Stroked borders

Property Values Default Description
-fx-border-color <paint> or <t> <r> <b> <l> [, ...]* null Paint colors for the border stroke layers.
-fx-border-insets <size> or <t> <r> <b> <l> [, ...]* null Insets from region edges for each border layer.
-fx-border-radius <size> [, ...]* null Corner radii for border stroke layers.
-fx-border-style <border-style> [, ...]* null Border line style (solid, dotted, dashed) plus phase and line cap/join options per layer.
-fx-border-width <size> or <t> <r> <b> <l> [, ...]* null Thickness of each border stroke layer, per side.

Border images

Property Values Default Description
-fx-border-image-source <uri> [, <uri>]* null Image URIs used to paint the border.
-fx-border-image-insets <size> or <t> <r> <b> <l> [, ...]* 0 0 0 0 Insets for each border image layer.
-fx-border-image-repeat <repeat-style> [, ...]* repeat repeat Tiling behavior for each border image.
-fx-border-image-slice <size> or <t> <r> <b> <l> [fill] [, ...]* 100% Divides each border image into nine regions. Adding fill preserves the center region.
-fx-border-image-width <size> or <t> <r> <b> <l> [, ...]* 1 1 1 1 Width of each border image slice per side.

Other Region properties

Property Values Default Description
-fx-padding <size> or <t> <r> <b> <l> 0 0 0 0 Interior padding between the region border and its content.
-fx-shape <string> null SVG path string that defines a custom clip shape for the region.
-fx-scale-shape true | false true When true, the shape is scaled to fit the region.
-fx-position-shape true | false true When true, the shape is centered within the region.
-fx-snap-to-pixel true | false true When true, positions and sizes are rounded to whole pixel boundaries.
-fx-min-width <size> -1 Minimum width. -1 uses the computed minimum.
-fx-pref-width <size> -1 Preferred width. -1 uses the computed preferred.
-fx-max-width <size> -1 Maximum width. -1 uses the computed maximum.
-fx-min-height <size> -1 Minimum height. -1 uses the computed minimum.
-fx-pref-height <size> -1 Preferred height. -1 uses the computed preferred.
-fx-max-height <size> -1 Maximum height. -1 uses the computed maximum.

CSS Properties -- Node

Property Values Default Description
-fx-blend-mode add | blue | color-burn | color-dodge | darken | difference | exclusion | green | hard-light | lighten | multiply | overlay | red | screen | soft-light | src-atop | src-in | src-out | src-over null Blend mode used when compositing this node with nodes beneath it.
-fx-cursor null | crosshair | default | hand | move | e-resize | h-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | v-resize | text | wait | <url> null (inherits) Mouse cursor shape shown when the pointer is over this node. Inherits from parent by default.
-fx-effect <effect> null A visual effect (e.g. DropShadow, InnerShadow) applied to the rendered node.
-fx-focus-traversable true | false false Whether this node participates in focus traversal. Overridden to true by Control.
-fx-view-order <number> 0 Adjusts rendering and hit-test order within the parent without changing the scene graph order.
-fx-opacity <number> [0.0 - 1.0] 1 Opacity of the node. 0 is fully transparent, 1 is fully opaque.
-fx-rotate <number> 0 Rotation angle in degrees applied around the node's center point. Positive values are clockwise.
-fx-scale-x <number> 1 Scale factor along the X axis about the node's center.
-fx-scale-y <number> 1 Scale factor along the Y axis about the node's center.
-fx-scale-z <number> 1 Scale factor along the Z axis about the node's center.
-fx-translate-x <number> 0 Translation offset along the X axis in pixels.
-fx-translate-y <number> 0 Translation offset along the Y axis in pixels.
-fx-translate-z <number> 0 Translation offset along the Z axis in pixels.
visibility visible | hidden | collapse | inherit visible Controls whether the node is rendered and participates in layout. collapse removes it from layout; hidden keeps the space.
-fx-managed true | false true When false, the parent layout does not manage this node's position or size.

Methods

  • ComboBox (Val)

    Constructor that takes a list of items to set.

    • @p Val is a list of items to set.
    • @r this object
  • setItems (list lst)

    Sets a list of items for the ComboBox.

    • @p lst is a list of items to set.
    • @r this object
  • getValue ()

    Gets the current selected object.

    • @r The value.
  • setVisibleRows (int Count)

    Sets the number of visible rows to show in the ComboBox.

    • @p Count is an int with the number of rows to show.
    • @r this object
  • onChange (callback OnChange)

    Sets the on change handler callback function. Callback example: onComboBoxChange(ObservableValue, OldValue, NewValue)

    • @p OnChange is a callback function to call on change.
    • @r this object
  • getItems ()

    Returns the items list as an AJO ObservableList.

    • @r An AJO around the ObservableList of items.
  • itemsProperty ()

    Returns the ObjectProperty AJO for the items list.

    • @r An AJO around the items ObjectProperty.
  • getConverter ()

    Returns the StringConverter AJO used to convert items to strings.

    • @r An AJO around the StringConverter or null.
  • setConverter (object Converter)

    Sets the StringConverter used to convert items to strings.

    • @p Converter is an AJO around a javafx.util.StringConverter.
    • @r this object for chaining
  • converterProperty ()

    Returns the ObjectProperty AJO for the converter.

    • @r An AJO around the converter ObjectProperty.
  • getCellFactory ()

    Returns the cell factory Callback AJO.

    • @r An AJO around the cell factory Callback or null.
  • setCellFactory (callback Cb)

    Sets the cell factory Callback used to build list cells.

    • @p Cb is a callback function (SAM) invoked with the ListView AJO.
    • @r this object for chaining
  • cellFactoryProperty ()

    Returns the ObjectProperty AJO for the cell factory.

    • @r An AJO around the cellFactory ObjectProperty.
  • getButtonCell ()

    Returns the button cell AJO used as the displayed cell.

    • @r An AJO around the button ListCell or null.
  • setButtonCell (object Cell)

    Sets the button cell used as the displayed cell.

    • @p Cell is an AJO around a javafx.scene.control.ListCell.
    • @r this object for chaining
  • buttonCellProperty ()

    Returns the ObjectProperty AJO for the button cell.

    • @r An AJO around the buttonCell ObjectProperty.
  • getSelectionModel ()

    Returns the SingleSelectionModel AJO used by this ComboBox.

    • @r An AJO around the SingleSelectionModel.
  • setSelectionModel (object Model)

    Sets the SingleSelectionModel for this ComboBox.

    • @p Model is an AJO around a javafx.scene.control.SingleSelectionModel.
    • @r this object for chaining
  • selectionModelProperty ()

    Returns the ObjectProperty AJO for the selection model.

    • @r An AJO around the selectionModel ObjectProperty.
  • getVisibleRowCount ()

    Returns the configured visible row count.

    • @r An int with the visible row count.
  • setVisibleRowCount (int Count)

    Sets the visible row count for the popup list.

    • @p Count is an int with the row count.
    • @r this object for chaining
  • visibleRowCountProperty ()

    Returns the IntegerProperty AJO for the visible row count.

    • @r An AJO around the visibleRowCount IntegerProperty.
  • getEditor ()

    Returns the editor TextField AJO used in editable mode.

    • @r An AJO around the editor TextField.
  • editorProperty ()

    Returns the read-only ObjectProperty AJO for the editor.

    • @r An AJO around the editor ReadOnlyObjectProperty.
  • getPlaceholder ()

    Returns the placeholder Node AJO shown when the list is empty.

    • @r An AJO around the placeholder Node or null.
  • setPlaceholder (object NodeObj)

    Sets the placeholder Node shown when the list is empty.

    • @p NodeObj is a Node wrapper for the placeholder.
    • @r this object for chaining
  • placeholderProperty ()

    Returns the ObjectProperty AJO for the placeholder.

    • @r An AJO around the placeholder ObjectProperty.
  • commitValue ()

    Commits the current editor text into the value property.

    • @r this object for chaining
  • cancelEdit ()

    Cancels the in-progress edit and reverts the editor text.

    • @r this object for chaining
  • queryAccessibleAttribute (string Attr)

    Queries an accessibility attribute value.

    • @p Attr is an AccessibleAttribute enum name (e.g. "TEXT").
    • @r The attribute value as returned by JavaFX.