Class SuperComboBox

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class SuperComboBox
    extends JPanel
    SuperComboBox is a complete rewrite of JComboBox; it does not extend JComboBox (!) Items added may implement NamedObject, in which case getName() is used as the row name, and getDescription() is used as the tooltip. Otherwise, o.toString() is used as the row name, and there is no tooltip. The row names must be unique. An ActionValueEvent is thrown when the selection is changed through manipulation of the widget. The selection can be obtained from actionEvent.getValue(), which returns the the selection row name. The caller can change the selection by calling setSelectionByName(). In this case, no event is thrown.
    See Also:
    Serialized Form
    • Constructor Detail

      • SuperComboBox

        public SuperComboBox​(RootPaneContainer parent,
                             String name,
                             boolean sortOK,
                             Iterator iter)
        default is one column, with an iterator of NamedObjects
        Parameters:
        parent - parent container
        name - column name
        sortOK - true allow sorting, column adding and removing
        iter - Iterator of objects inside the combobox.
    • Method Detail

      • addActionValueListener

        public void addActionValueListener​(ActionValueListener l)
        add ActionValueListener listener
      • removeActionValueListener

        public void removeActionValueListener​(ActionValueListener l)
        remove ActionValueListener listener
      • getActionSourceListener

        public ActionSourceListener getActionSourceListener()
        better way to do event management
      • getLoopControl

        public IndependentWindow getLoopControl()
        get the LoopControl Window associated with this list
      • getName

        public String getName()
        get the name associated with this list
        Overrides:
        getName in class Component
      • setCollection

        public void setCollection​(Iterator iter)
        Set the list of things to be selected. Iterator may return objects of type NamedObjects, otherwise will use object.toString()
      • setCollection

        public void setCollection​(Iterator iter,
                                  boolean keepIndex)
      • setLabel

        public void setLabel​(String s)
        Set the displayed text. Typically its only used when the list is empty.
      • getSelectedObject

        @Nullable
        public Object getSelectedObject()
        Get the currently selected object. May be null.
      • getSelectedIndex

        public int getSelectedIndex()
        Get the index of the currently selected object in the list. If sortOK, then this may not be the original index.
        Returns:
        index of selected object, or -1 if none selected.
      • setSelectedByName

        public int setSelectedByName​(String choiceName)
        Set the currently selected object using its choice name. Note that no event is sent due to this call.
        Parameters:
        choiceName - name of object to match.
        Returns:
        index of selection, or -1 if not found;
      • setSelectedByValue

        public int setSelectedByValue​(Object choice)
      • setSelectedByIndex

        public void setSelectedByIndex​(int index)
        Set the currently selected object using its index. If sortOK, then this may not be the original index.
        Parameters:
        index - of selected object.