All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, DocumentListener

public class SearchBar extends JPanel implements DocumentListener

SearchBar is a text field, a toggle for case-sensitive, and a toggle for regular expressions.

When the text changes, it fires a property change event for the value "match" with the new text.

See Also:
  • Constructor Details

    • SearchBar

      public SearchBar()
    • SearchBar

      public SearchBar(String text)
  • Method Details

    • insertUpdate

      public void insertUpdate(DocumentEvent e)
      Specified by:
      insertUpdate in interface DocumentListener
    • removeUpdate

      public void removeUpdate(DocumentEvent e)
      Specified by:
      removeUpdate in interface DocumentListener
    • changedUpdate

      public void changedUpdate(DocumentEvent e)
      Specified by:
      changedUpdate in interface DocumentListener
    • fireMatchChange

      public void fireMatchChange()
    • getRegex

      public boolean getRegex()
    • setRegex

      public void setRegex(boolean regex)
    • getCaseSensitive

      public boolean getCaseSensitive()
    • setCaseSensitive

      public void setCaseSensitive(boolean caseSensitive)
    • matches

      public boolean matches(String text)
      Does the given text match the search criteria?
      Parameters:
      text - the text to match
      Returns:
      true if the text matches the search criteria
    • setSearchText

      public void setSearchText(String text)
      Set the text in the search bar.
      Parameters:
      text - the text to search for. Can be a regular expression.
    • getSearchText

      public String getSearchText()
      Get the text in the search bar.
      Returns:
      the text to search for. Can be a regular expression.