Class ComboBoxBase<T>

Type Parameters:
T - The type of the value that has been selected or otherwise entered in to this ComboBox.
All Implemented Interfaces:
Styleable, EventTarget, Skinnable
Direct Known Subclasses:
ColorPicker, ComboBox, DatePicker

public abstract class ComboBoxBase<T>
extends Control
Abstract base class for ComboBox-like controls. A ComboBox typically has a button that, when clicked, will pop up some means of allowing a user to select one or more values (depending on the implementation). This base class makes no assumptions about what happens when the show() and hide() methods are called, however commonly this results in either a popup or dialog appearing that allows for the user to provide the required information.

A ComboBox has a value property that represents the current user input. This may be based on a selection from a drop-down list, or it may be from user input when the ComboBox is editable.

An editable ComboBox is one which provides some means for an end-user to provide input for values that are not otherwise options available to them. For example, in the ComboBox implementation, an editable ComboBox provides a TextField that may be typed into. As mentioned above, when the user commits textual input into the textfield (commonly by pressing the Enter keyboard key), the value property will be updated.

The purpose of the separation between this class and, say, ComboBox is to allow for ComboBox-like controls that do not necessarily pop up a list of items. Examples of other implementations include color pickers, calendar pickers, etc. The ComboBox class provides the default, and most commonly expected implementation. Refer to that classes javadoc for more information.

Since:
JavaFX 2.1
See Also:
ComboBox
  • Property Details

    • value

      public ObjectProperty<T> valueProperty
      The value of this ComboBox is defined as the selected item if the input is not editable, or if it is editable, the most recent user action: either the value input by the user, or the last selected item.
      See Also:
      getValue(), setValue(T)
    • editable

      public BooleanProperty editableProperty
      Specifies whether the ComboBox allows for user input. When editable is true, the ComboBox has a text input area that a user may type in to. This input is then available via the value property.

      Note that when the editable property changes, the value property is reset, along with any other relevant state.

      See Also:
      isEditable(), setEditable(boolean)
    • showing

      public ReadOnlyBooleanProperty showingProperty
      Represents the current state of the ComboBox popup, and whether it is currently visible on screen (although it may be hidden behind other windows).
      See Also:
      isShowing()
    • promptText

      public final StringProperty promptTextProperty
      The ComboBox prompt text to display, or null if no prompt text is displayed. Prompt text is not displayed in all circumstances, it is dependent upon the subclasses of ComboBoxBase to clarify when promptText will be shown. For example, in most cases prompt text will never be shown when a combo box is non-editable (that is, prompt text is only shown when user input is allowed via text input).
      See Also:
      getPromptText(), setPromptText(String)
    • armed

      public BooleanProperty armedProperty
      Indicates that the ComboBox has been "armed" such that a mouse release will cause the ComboBox show() method to be invoked. This is subtly different from pressed. Pressed indicates that the mouse has been pressed on a Node and has not yet been released. arm however also takes into account whether the mouse is actually over the ComboBox and pressed.
      See Also:
      isArmed()
    • onAction

      public final ObjectProperty<EventHandler<ActionEvent>> onActionProperty
      The ComboBox action, which is invoked whenever the ComboBox value property is changed. This may be due to the value property being programmatically changed, when the user selects an item in a popup list or dialog, or, in the case of editable ComboBoxes, it may be when the user provides their own input (be that via a TextField or some other input mechanism.
      See Also:
      getOnAction(), setOnAction(EventHandler)
    • onShowing

      public final ObjectProperty<EventHandler<Event>> onShowingProperty
      Called just prior to the ComboBoxBase popup/display being shown.
      Since:
      JavaFX 2.2
      See Also:
      getOnShowing(), setOnShowing(EventHandler)
    • onShown

      public final ObjectProperty<EventHandler<Event>> onShownProperty
      Called just after the ComboBoxBase popup/display is shown.
      Since:
      JavaFX 2.2
      See Also:
      getOnShown(), setOnShown(EventHandler)
    • onHiding

      public final ObjectProperty<EventHandler<Event>> onHidingProperty
      Called just prior to the ComboBox popup/display being hidden.
      Since:
      JavaFX 2.2
      See Also:
      getOnHiding(), setOnHiding(EventHandler)
    • onHidden

      public final ObjectProperty<EventHandler<Event>> onHiddenProperty
      Called just after the ComboBoxBase popup/display has been hidden.
      Since:
      JavaFX 2.2
      See Also:
      getOnHidden(), setOnHidden(EventHandler)
  • Field Details

    • ON_SHOWING

      public static final EventType<Event> ON_SHOWING

      Called prior to the ComboBox showing its popup/display after the user has clicked or otherwise interacted with the ComboBox.

      Since:
      JavaFX 2.2
    • ON_SHOWN

      public static final EventType<Event> ON_SHOWN

      Called after the ComboBox has shown its popup/display.

      Since:
      JavaFX 2.2
    • ON_HIDING

      public static final EventType<Event> ON_HIDING

      Called when the ComboBox popup/display will be hidden.

      Since:
      JavaFX 2.2
    • ON_HIDDEN

      public static final EventType<Event> ON_HIDDEN

      Called when the ComboBox popup/display has been hidden.

      Since:
      JavaFX 2.2
  • Constructor Details

    • ComboBoxBase

      public ComboBoxBase()
      Creates a default ComboBoxBase instance.
  • Method Details

    • valueProperty

      public ObjectProperty<T> valueProperty()
      The value of this ComboBox is defined as the selected item if the input is not editable, or if it is editable, the most recent user action: either the value input by the user, or the last selected item.
      See Also:
      getValue(), setValue(T)
    • setValue

      public final void setValue​(T value)
      Sets the value of the property value.
      Property description:
      The value of this ComboBox is defined as the selected item if the input is not editable, or if it is editable, the most recent user action: either the value input by the user, or the last selected item.
    • getValue

      public final T getValue()
      Gets the value of the property value.
      Property description:
      The value of this ComboBox is defined as the selected item if the input is not editable, or if it is editable, the most recent user action: either the value input by the user, or the last selected item.
    • editableProperty

      public BooleanProperty editableProperty()
      Specifies whether the ComboBox allows for user input. When editable is true, the ComboBox has a text input area that a user may type in to. This input is then available via the value property.

      Note that when the editable property changes, the value property is reset, along with any other relevant state.

      See Also:
      isEditable(), setEditable(boolean)
    • setEditable

      public final void setEditable​(boolean value)
      Sets the value of the property editable.
      Property description:
      Specifies whether the ComboBox allows for user input. When editable is true, the ComboBox has a text input area that a user may type in to. This input is then available via the value property.

      Note that when the editable property changes, the value property is reset, along with any other relevant state.

    • isEditable

      public final boolean isEditable()
      Gets the value of the property editable.
      Property description:
      Specifies whether the ComboBox allows for user input. When editable is true, the ComboBox has a text input area that a user may type in to. This input is then available via the value property.

      Note that when the editable property changes, the value property is reset, along with any other relevant state.

    • showingProperty

      public ReadOnlyBooleanProperty showingProperty()
      Represents the current state of the ComboBox popup, and whether it is currently visible on screen (although it may be hidden behind other windows).
      See Also:
      isShowing()
    • isShowing

      public final boolean isShowing()
      Gets the value of the property showing.
      Property description:
      Represents the current state of the ComboBox popup, and whether it is currently visible on screen (although it may be hidden behind other windows).
    • promptTextProperty

      public final StringProperty promptTextProperty()
      The ComboBox prompt text to display, or null if no prompt text is displayed. Prompt text is not displayed in all circumstances, it is dependent upon the subclasses of ComboBoxBase to clarify when promptText will be shown. For example, in most cases prompt text will never be shown when a combo box is non-editable (that is, prompt text is only shown when user input is allowed via text input).
      See Also:
      getPromptText(), setPromptText(String)
    • getPromptText

      public final String getPromptText()
      Gets the value of the property promptText.
      Property description:
      The ComboBox prompt text to display, or null if no prompt text is displayed. Prompt text is not displayed in all circumstances, it is dependent upon the subclasses of ComboBoxBase to clarify when promptText will be shown. For example, in most cases prompt text will never be shown when a combo box is non-editable (that is, prompt text is only shown when user input is allowed via text input).
    • setPromptText

      public final void setPromptText​(String value)
      Sets the value of the property promptText.
      Property description:
      The ComboBox prompt text to display, or null if no prompt text is displayed. Prompt text is not displayed in all circumstances, it is dependent upon the subclasses of ComboBoxBase to clarify when promptText will be shown. For example, in most cases prompt text will never be shown when a combo box is non-editable (that is, prompt text is only shown when user input is allowed via text input).
    • armedProperty

      public BooleanProperty armedProperty()
      Indicates that the ComboBox has been "armed" such that a mouse release will cause the ComboBox show() method to be invoked. This is subtly different from pressed. Pressed indicates that the mouse has been pressed on a Node and has not yet been released. arm however also takes into account whether the mouse is actually over the ComboBox and pressed.
      See Also:
      isArmed()
    • isArmed

      public final boolean isArmed()
      Gets the value of the property armed.
      Property description:
      Indicates that the ComboBox has been "armed" such that a mouse release will cause the ComboBox show() method to be invoked. This is subtly different from pressed. Pressed indicates that the mouse has been pressed on a Node and has not yet been released. arm however also takes into account whether the mouse is actually over the ComboBox and pressed.
    • onActionProperty

      public final ObjectProperty<EventHandler<ActionEvent>> onActionProperty()
      The ComboBox action, which is invoked whenever the ComboBox value property is changed. This may be due to the value property being programmatically changed, when the user selects an item in a popup list or dialog, or, in the case of editable ComboBoxes, it may be when the user provides their own input (be that via a TextField or some other input mechanism.
      See Also:
      getOnAction(), setOnAction(EventHandler)
    • setOnAction

      public final void setOnAction​(EventHandler<ActionEvent> value)
      Sets the value of the property onAction.
      Property description:
      The ComboBox action, which is invoked whenever the ComboBox value property is changed. This may be due to the value property being programmatically changed, when the user selects an item in a popup list or dialog, or, in the case of editable ComboBoxes, it may be when the user provides their own input (be that via a TextField or some other input mechanism.
    • getOnAction

      public final EventHandler<ActionEvent> getOnAction()
      Gets the value of the property onAction.
      Property description:
      The ComboBox action, which is invoked whenever the ComboBox value property is changed. This may be due to the value property being programmatically changed, when the user selects an item in a popup list or dialog, or, in the case of editable ComboBoxes, it may be when the user provides their own input (be that via a TextField or some other input mechanism.
    • onShowingProperty

      public final ObjectProperty<EventHandler<Event>> onShowingProperty()
      Called just prior to the ComboBoxBase popup/display being shown.
      Since:
      JavaFX 2.2
      See Also:
      getOnShowing(), setOnShowing(EventHandler)
    • setOnShowing

      public final void setOnShowing​(EventHandler<Event> value)
      Sets the value of the property onShowing.
      Property description:
      Called just prior to the ComboBoxBase popup/display being shown.
      Since:
      JavaFX 2.2
    • getOnShowing

      public final EventHandler<Event> getOnShowing()
      Gets the value of the property onShowing.
      Property description:
      Called just prior to the ComboBoxBase popup/display being shown.
      Since:
      JavaFX 2.2
    • onShownProperty

      public final ObjectProperty<EventHandler<Event>> onShownProperty()
      Called just after the ComboBoxBase popup/display is shown.
      Since:
      JavaFX 2.2
      See Also:
      getOnShown(), setOnShown(EventHandler)
    • setOnShown

      public final void setOnShown​(EventHandler<Event> value)
      Sets the value of the property onShown.
      Property description:
      Called just after the ComboBoxBase popup/display is shown.
      Since:
      JavaFX 2.2
    • getOnShown

      public final EventHandler<Event> getOnShown()
      Gets the value of the property onShown.
      Property description:
      Called just after the ComboBoxBase popup/display is shown.
      Since:
      JavaFX 2.2
    • onHidingProperty

      public final ObjectProperty<EventHandler<Event>> onHidingProperty()
      Called just prior to the ComboBox popup/display being hidden.
      Since:
      JavaFX 2.2
      See Also:
      getOnHiding(), setOnHiding(EventHandler)
    • setOnHiding

      public final void setOnHiding​(EventHandler<Event> value)
      Sets the value of the property onHiding.
      Property description:
      Called just prior to the ComboBox popup/display being hidden.
      Since:
      JavaFX 2.2
    • getOnHiding

      public final EventHandler<Event> getOnHiding()
      Gets the value of the property onHiding.
      Property description:
      Called just prior to the ComboBox popup/display being hidden.
      Since:
      JavaFX 2.2
    • onHiddenProperty

      public final ObjectProperty<EventHandler<Event>> onHiddenProperty()
      Called just after the ComboBoxBase popup/display has been hidden.
      Since:
      JavaFX 2.2
      See Also:
      getOnHidden(), setOnHidden(EventHandler)
    • setOnHidden

      public final void setOnHidden​(EventHandler<Event> value)
      Sets the value of the property onHidden.
      Property description:
      Called just after the ComboBoxBase popup/display has been hidden.
      Since:
      JavaFX 2.2
    • getOnHidden

      public final EventHandler<Event> getOnHidden()
      Gets the value of the property onHidden.
      Property description:
      Called just after the ComboBoxBase popup/display has been hidden.
      Since:
      JavaFX 2.2
    • show

      public void show()
      Requests that the ComboBox display the popup aspect of the user interface. As mentioned in the ComboBoxBase class javadoc, what is actually shown when this method is called is undefined, but commonly it is some form of popup or dialog window.
    • hide

      public void hide()
      Closes the popup / dialog that was shown when show() was called.
    • arm

      public void arm()
      Arms the ComboBox. An armed ComboBox will show a popup list on the next expected UI gesture. Note: This function is intended to be used by experts, primarily by those implementing new Skins or Behaviors. It is not common for developers or designers to access this function directly.
    • disarm

      public void disarm()
      Disarms the ComboBox. See arm(). Note: This function is intended to be used by experts, primarily by those implementing new Skins or Behaviors. It is not common for developers or designers to access this function directly.
    • queryAccessibleAttribute

      public Object queryAccessibleAttribute​(AccessibleAttribute attribute, Object... parameters)
      This method is called by the assistive technology to request the value for an attribute.

      This method is commonly overridden by subclasses to implement attributes that are required for a specific role.
      If a particular attribute is not handled, the superclass implementation must be called.

      Overrides:
      queryAccessibleAttribute in class Control
      Parameters:
      attribute - the requested attribute
      parameters - optional list of parameters
      Returns:
      the value for the requested attribute
      See Also:
      AccessibleAttribute
    • executeAccessibleAction

      public void executeAccessibleAction​(AccessibleAction action, Object... parameters)
      This method is called by the assistive technology to request the action indicated by the argument should be executed.

      This method is commonly overridden by subclasses to implement action that are required for a specific role.
      If a particular action is not handled, the superclass implementation must be called.

      Overrides:
      executeAccessibleAction in class Control
      Parameters:
      action - the action to execute
      parameters - optional list of parameters
      See Also:
      AccessibleAction