Class DropdownButton

  • All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    @DefaultProperty("items")
    public class DropdownButton
    extends Control
    A Dropdown button selects between multiple selections. The button displays the current state and a down arrow. When a user interacts with the button, a menu covers the button and displays the possible states. Pressing a state dismisses the menu and updates the button to display this new state.

    Example

    The following code creates and assigns a list of choices to a Dropdown button, in the last instruction it assigns "Choice 1" as the selected choice.

     
     DropdownButton dropdownButton = new DropdownButton();
     MenuItem menuItem = new MenuItem("Choice 1");
     dropdownButton.getItems().addAll(menuItem, new MenuItem("Choice 2"), new MenuItem("Choice 3"), new MenuItem("Choice 4"));
     dropdownButton.setSelectedItem(menuItem);
     
     
    Screenshot of DropdownButton
    Since:
    2.0.0
    • Constructor Detail

      • DropdownButton

        public DropdownButton()
        Creates an empty Dropdown button.
    • Method Detail

      • setSelectedItem

        public final void setSelectedItem​(MenuItem value)
        Sets the value of the property selectedItem.
        Property description:
        Specifies which item is selected in the DropdownButton.
      • getSelectedItem

        public final MenuItem getSelectedItem()
        Gets the value of the property selectedItem.
        Property description:
        Specifies which item is selected in the DropdownButton.