Class SearchBar

All Implemented Interfaces:
Styleable, EventTarget

public class SearchBar extends VBox
The SearchBar class represents a UI component that provides a text field for users to enter search queries and a button to search.
  • Field Details

    • searchField

      private final TextField searchField
      The text field for users to enter their search queries.
    • searchButton

      private final Button searchButton
      The button that users click to initiate the search based on the entered query.
    • sortingOptionDropdown

      private final ComboBox<RowComparator> sortingOptionDropdown
      The dropdown for users to select the sorting option for search results.
  • Constructor Details

    • SearchBar

      public SearchBar()
      Constructor for SearchBar. Initializes the search field and button, adds them to the HBox.
      Preconditions:
      The SearchBar should be properly initialized to allow for user interaction with the search field and button.
  • Method Details

    • buildSortingOptionDropdown

      private void buildSortingOptionDropdown(HBox bottomBox, Label sortByLabel)
      Builds the dropdown for the Sort By selections.
      Parameters:
      bottomBox - The HBox to add the sortingOptionDropdown to.
      sortByLabel - The Label to associate with the sortingOptionDropdown in the UI.
      Preconditions:
      The sortingOptionDropdown should be properly initialized to allow for adding sorting options to it.
      Postconditions:
      The sortingOptionDropdown is built with the appropriate sorting options, callbacks are set for displaying the options and printing the selected option, and the dropdown is added to the provided bottomBox.
    • setSortingOptionCallbacks

      private void setSortingOptionCallbacks()
      Sets the callbacks for displaying a cell, selected item, and printing when an item is selected.
      Preconditions:
      The sortingOptionDropdown should be properly initialized with the expected items for the callbacks to function correctly.
      Postconditions:
      The callbacks for displaying a cell, selected item, and printing when an item is selected are set for the sortingOptionDropdown.
    • getSearchField

      public TextField getSearchField()
      Returns the TextField for entering search queries.
      Returns:
      The TextField for entering search queries.
    • getSearchButton

      public Button getSearchButton()
      Returns the Button for initiating the search.
      Returns:
      The Button for initiating the search.
    • getSortingOptionDropdown

      public ComboBox<RowComparator> getSortingOptionDropdown()
      Returns the ComboBox for selecting sorting options.
      Returns:
      The ComboBox for selecting sorting options.