Class FilterTextField

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FilterTextField extends JPanel
A text field that is meant to be used in conjunction with tables that allow filter text. This text field will change its background color when it contains text. Additionally, this text field will flash its background color when the associated component gains focus. This is done to remind the user that there is a filter applied.
See Also:
  • Constructor Details

    • FilterTextField

      public FilterTextField(Component component)
      Constructs this text field with the given component. component may be null, but then this field will be unable to flash in response to focus events (see the header documentation).
      Parameters:
      component - The component needed to listen for focus changes, may be null.
    • FilterTextField

      public FilterTextField(Component component, int columns)
      Constructs this text field with the given component and the preferred visible column width. component may be null, but then this field will be able to flash in response to focus events (see the header documentation).
      Parameters:
      component - The component needed to listen for focus changes, may be null.
      columns - The number of preferred visible columns (see JTextField)
  • Method Details

    • setFocusComponent

      public void setFocusComponent(Component component)
    • alert

      public void alert()
      This method will signal to the users if a filter is currently applied (has text). For example, the default implementation will 'flash' the filter by changing its background color multiple times.

      Note: this method will not perform the alert if the minimum time between alerts has not passed. To force the alter to take place, call alert(boolean) with a value of true.

    • alert

      public void alert(boolean forceAlert)
      This is the same as alert() with the exception that a true value for forceAlter will guarantee that the alert will happen. A false value will not perform the alert if the minimum time between alerts has not passed.
      Parameters:
      forceAlert - true signals to force the alter to take place.
      See Also:
    • isEditable

      public boolean isEditable()
    • setEditable

      public void setEditable(boolean b)
    • getText

      public String getText()
    • setText

      public void setText(String text)
    • addEnterListener

      public void addEnterListener(Callback callback)
      Adds the listener to this filter field that will be called when the user presses the enter key.

      Note: this listener cannot be anonymous, as the underlying storage mechanism may be using a weak data structure. This means that you will need to store the listener in a field inside of your class.

      Parameters:
      callback - the listener
    • removeEnterListener

      public void removeEnterListener(Callback callback)
    • addFilterListener

      public void addFilterListener(FilterListener l)
      Adds the filter listener to this filter field that will be called when the filter contents change.

      Note: this listener cannot be anonymous, as the underlying storage mechanism may be using a weak data structure. This means that you will need to store the listener in a field inside of your class.

      Parameters:
      l - the listener
    • removeFilterListener

      public void removeFilterListener(FilterListener l)
    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent
    • isEnabled

      public boolean isEnabled()
      Overrides:
      isEnabled in class Component
    • requestFocus

      public void requestFocus()
      Overrides:
      requestFocus in class JComponent
    • setAccessibleNamePrefix

      public void setAccessibleNamePrefix(String prefix)
      Sets the accessible name prefix for for the focusable components in the filter panel.
      Parameters:
      prefix - the base name for these components. A suffix will be added to further describe the sub component.