Klasse ComboBoxEx<T>

Typparameter:
T - the type of the items contained in the ComboBox
Alle implementierten Schnittstellen:
InputControl<T>, Styleable, EventTarget, Skinnable

public class ComboBoxEx<T> extends CustomControl<HBox> implements InputControl<T>
A custom ComboBox control that supports additional features like editing, adding, and removing items.
  • Eigenschaftsdetails

  • Konstruktordetails

    • ComboBoxEx

      @SafeVarargs public ComboBoxEx(@Nullable UnaryOperator<T> edit, @Nullable Supplier<T> add, @Nullable BiPredicate<ComboBoxEx<T>,T> remove, Function<T,String> format, T... items)
      Constructs a ComboBoxEx with the specified edit, add, remove, format, and items.
      Parameter:
      edit - the unary operator to perform editing on the selected item (nullable)
      add - the supplier to provide a new item to add (nullable)
      remove - the bi-predicate to determine if an item should be removed (nullable)
      format - the function to format the items as strings
      items - the initial items to populate the ComboBox (variadic parameter)
    • ComboBoxEx

      public ComboBoxEx(@Nullable UnaryOperator<T> edit, @Nullable Supplier<T> add, @Nullable BiPredicate<ComboBoxEx<T>,T> remove, Function<@Nullable T,String> format, Collection<T> items)
      Constructs a ComboBoxEx with the specified edit, add, remove, format, and items.
      Parameter:
      edit - the unary operator to perform editing on the selected item (nullable)
      add - the supplier to provide a new item to add (nullable)
      remove - the bi-predicate to determine if an item should be removed (nullable)
      format - the function to format the items as strings
      items - the initial items to populate the ComboBox (variadic parameter)
  • Methodendetails

    • askBeforeRemoveSelectedItem

      public boolean askBeforeRemoveSelectedItem(T item)
      Prompts the user with a confirmation dialogue to verify whether to remove the selected item.

      Pass this as the remove parameter to the constructor to show a confirmation dialog when the user wants to remove an item.

      Parameter:
      item - the item to be removed
      Gibt zurück:
      true if the user confirms the removal, false otherwise
    • alwaysRemoveSelectedItem

      public static <T> boolean alwaysRemoveSelectedItem(ComboBoxEx<T> cb, T item)
      Remove the selected item without showing a confirmation dialog.

      Pass this as the remove parameter to the constructor to remove items without showing a confirmation dialog.

      Typparameter:
      T - the type of items contained in the ComboBoxEx
      Parameter:
      cb - the ComboBoxEx to remove the item from
      item - the item to be removed
      Gibt zurück:
      true if the user confirms the removal, false otherwise
    • getSelectedItem

      public Optional<T> getSelectedItem()
      Retrieves the currently selected item from the ComboBoxEx.
      Gibt zurück:
      an Optional containing the selected item if one is selected, or an empty Optional if no item is selected
    • getItems

      public List<T> getItems()
      Retrieves a copy of the items in the ComboBoxEx.
      Gibt zurück:
      an immutable list containing the current items in the ComboBoxEx
    • selectedItemProperty

      public ReadOnlyObjectProperty<T> selectedItemProperty()
      Returns the property containing the selected item in the ComboBoxEx.
      Gibt zurück:
      the ReadOnlyObjectProperty representing the selected item property
      Siehe auch:
    • setComparator

      public void setComparator(Comparator<? super T> comparator)
      Sets the comparator for the ComboBoxEx and sorts the items accordingly. If the comparator is null, the items will not be sorted.
      Parameter:
      comparator - the comparator to set, which is used for sorting the items
    • sortItems

      public void sortItems()
      Sorts the items in the ComboBoxEx using the defined comparator. If the comparator is null, the method returns without performing any action. The currently selected item, if any, will remain selected after sorting.
    • node

      public Node node()
      Beschreibung aus Schnittstelle kopiert: InputControl
      Get the Node for this input element.
      Angegeben von:
      node in Schnittstelle InputControl<T>
      Gibt zurück:
      the node
    • valueProperty

      public Property<@Nullable T> valueProperty()
      Beschreibung aus Schnittstelle kopiert: InputControl
      Provides the property representing the value of this input control.
      Angegeben von:
      valueProperty in Schnittstelle InputControl<T>
      Gibt zurück:
      die Eigenschaft value
    • reset

      public void reset()
      Beschreibung aus Schnittstelle kopiert: InputControl
      Reset value to default
      Angegeben von:
      reset in Schnittstelle InputControl<T>
    • validProperty

      public ReadOnlyBooleanProperty validProperty()
      Beschreibung aus Schnittstelle kopiert: InputControl
      Provides a read-only property representing the validity of the input.
      Angegeben von:
      validProperty in Schnittstelle InputControl<T>
      Gibt zurück:
      die Eigenschaft valid
    • errorProperty

      public ReadOnlyStringProperty errorProperty()
      Beschreibung aus Schnittstelle kopiert: InputControl
      Provides a read-only property representing the error message for this input control.

      This property contains an error message if the input is invalid, otherwise it is empty.

      Angegeben von:
      errorProperty in Schnittstelle InputControl<T>
      Gibt zurück:
      die Eigenschaft error