+
+ +

Class SearchBoxList

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • java.awt.Component
    • +
    • +
        +
      • java.awt.Container
      • +
      • +
          +
        • javax.swing.JComponent
        • +
        • +
            +
          • javax.swing.JPanel
          • +
          • +
              +
            • org.unitConverter.converterGUI.SearchBoxList
            • +
            +
          • +
          +
        • +
        +
      • +
      +
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
    +
    +
    +
    final class SearchBoxList
    +extends javax.swing.JPanel
    +
    +
    Since:
    +
    2019-04-13, v0.2.0
    +
    Author:
    +
    Adrien Hopkins
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Nested Class Summary

      +
        +
      • + + +

        Nested classes/interfaces inherited from class javax.swing.JPanel

        +javax.swing.JPanel.AccessibleJPanel
      • +
      +
        +
      • + + +

        Nested classes/interfaces inherited from class javax.swing.JComponent

        +javax.swing.JComponent.AccessibleJComponent
      • +
      +
        +
      • + + +

        Nested classes/interfaces inherited from class java.awt.Container

        +java.awt.Container.AccessibleAWTContainer
      • +
      +
        +
      • + + +

        Nested classes/interfaces inherited from class java.awt.Component

        +java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeFieldDescription
      private booleancaseSensitive 
      private java.util.function.Predicate<java.lang.String>customSearchFilter 
      private java.util.Comparator<java.lang.String>defaultOrdering 
      private static java.awt.ColorEMPTY_FOREGROUND +
      The color to use for an empty foreground.
      +
      private static java.lang.StringEMPTY_TEXT +
      The text to place in an empty search box.
      +
      private java.util.Collection<java.lang.String>itemsToFilter 
      private DelegateListModel<java.lang.String>listModel 
      private javax.swing.JTextFieldsearchBox 
      private booleansearchBoxEmpty 
      private booleansearchBoxFocused 
      private javax.swing.JList<java.lang.String>searchItems 
      private static longserialVersionUID 
      +
        +
      • + + +

        Fields inherited from class javax.swing.JComponent

        +listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
      • +
      +
        +
      • + + +

        Fields inherited from class java.awt.Component

        +accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • +
      +
        +
      • + + +

        Fields inherited from interface java.awt.image.ImageObserver

        +ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      SearchBoxList​(java.util.Collection<java.lang.String> itemsToFilter) +
      Creates the SearchBoxList.
      +
      SearchBoxList​(java.util.Collection<java.lang.String> itemsToFilter, + java.util.Comparator<java.lang.String> defaultOrdering, + boolean caseSensitive) +
      Creates the SearchBoxList.
      +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidaddSearchFilter​(java.util.function.Predicate<java.lang.String> filter) +
      Adds an additional filter for searching.
      +
      voidclearSearchFilters() +
      Resets the search filter.
      +
      javax.swing.JTextFieldgetSearchBox() 
      private java.util.function.Predicate<java.lang.String>getSearchFilter​(java.lang.String searchText) 
      javax.swing.JList<java.lang.String>getSearchList() 
      intgetSelectedIndex() 
      java.lang.StringgetSelectedValue() 
      voidreapplyFilter() +
      Re-applies the filters.
      +
      private voidsearchBoxFocusGained​(java.awt.event.FocusEvent e) +
      Runs whenever the search box gains focus.
      +
      private voidsearchBoxFocusLost​(java.awt.event.FocusEvent e) +
      Runs whenever the search box loses focus.
      +
      private voidsearchBoxTextChanged() +
      Runs whenever the text in the search box is changed.
      +
      +
        +
      • + + +

        Methods inherited from class javax.swing.JPanel

        +getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • +
      +
        +
      • + + +

        Methods inherited from class javax.swing.JComponent

        +addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • +
      +
        +
      • + + +

        Methods inherited from class java.awt.Container

        +add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • +
      +
        +
      • + + +

        Methods inherited from class java.awt.Component

        +action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        serialVersionUID

        +
        private static final long serialVersionUID
        +
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        EMPTY_TEXT

        +
        private static final java.lang.String EMPTY_TEXT
        +
        The text to place in an empty search box.
        +
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        EMPTY_FOREGROUND

        +
        private static final java.awt.Color EMPTY_FOREGROUND
        +
        The color to use for an empty foreground.
        +
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        itemsToFilter

        +
        private final java.util.Collection<java.lang.String> itemsToFilter
        +
      • +
      + + + + + + + +
        +
      • +

        searchBox

        +
        private final javax.swing.JTextField searchBox
        +
      • +
      + + + +
        +
      • +

        searchItems

        +
        private final javax.swing.JList<java.lang.String> searchItems
        +
      • +
      + + + +
        +
      • +

        searchBoxEmpty

        +
        private boolean searchBoxEmpty
        +
      • +
      + + + +
        +
      • +

        searchBoxFocused

        +
        private boolean searchBoxFocused
        +
      • +
      + + + +
        +
      • +

        customSearchFilter

        +
        private java.util.function.Predicate<java.lang.String> customSearchFilter
        +
      • +
      + + + +
        +
      • +

        defaultOrdering

        +
        private final java.util.Comparator<java.lang.String> defaultOrdering
        +
      • +
      + + + +
        +
      • +

        caseSensitive

        +
        private final boolean caseSensitive
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        SearchBoxList

        +
        public SearchBoxList​(java.util.Collection<java.lang.String> itemsToFilter)
        +
        Creates the SearchBoxList.
        +
        +
        Parameters:
        +
        itemsToFilter - items to put in the list
        +
        Since:
        +
        2019-04-14
        +
        +
      • +
      + + + +
        +
      • +

        SearchBoxList

        +
        public SearchBoxList​(java.util.Collection<java.lang.String> itemsToFilter,
        +                     java.util.Comparator<java.lang.String> defaultOrdering,
        +                     boolean caseSensitive)
        +
        Creates the SearchBoxList.
        +
        +
        Parameters:
        +
        itemsToFilter - items to put in the list
        +
        defaultOrdering - default ordering of items after filtration (null=Comparable)
        +
        caseSensitive - whether or not the filtration is case-sensitive
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        addSearchFilter

        +
        public void addSearchFilter​(java.util.function.Predicate<java.lang.String> filter)
        +
        Adds an additional filter for searching.
        +
        +
        Parameters:
        +
        filter - filter to add.
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        clearSearchFilters

        +
        public void clearSearchFilters()
        +
        Resets the search filter.
        +
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        getSearchBox

        +
        public final javax.swing.JTextField getSearchBox()
        +
        +
        Returns:
        +
        this component's search box component
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        getSearchFilter

        +
        private java.util.function.Predicate<java.lang.String> getSearchFilter​(java.lang.String searchText)
        +
        +
        Parameters:
        +
        searchText - text to search for
        +
        Returns:
        +
        a filter that filters out that text, based on this list's case sensitive setting
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        getSearchList

        +
        public final javax.swing.JList<java.lang.String> getSearchList()
        +
        +
        Returns:
        +
        this component's list component
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        getSelectedIndex

        +
        public int getSelectedIndex()
        +
        +
        Returns:
        +
        index selected in item list
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        getSelectedValue

        +
        public java.lang.String getSelectedValue()
        +
        +
        Returns:
        +
        value selected in item list
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        reapplyFilter

        +
        public void reapplyFilter()
        +
        Re-applies the filters.
        +
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        searchBoxFocusGained

        +
        private void searchBoxFocusGained​(java.awt.event.FocusEvent e)
        +
        Runs whenever the search box gains focus.
        +
        +
        Parameters:
        +
        e - focus event
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        searchBoxFocusLost

        +
        private void searchBoxFocusLost​(java.awt.event.FocusEvent e)
        +
        Runs whenever the search box loses focus.
        +
        +
        Parameters:
        +
        e - focus event
        +
        Since:
        +
        2019-04-13, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        searchBoxTextChanged

        +
        private void searchBoxTextChanged()
        +
        Runs whenever the text in the search box is changed. +

        + Reapplies the search filter, and custom filters. +

        +
        +
        Since:
        +
        2019-04-14, v0.2.0
        +
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+