Package docking.widgets.combobox

# Class GhidraComboBox<E>

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox<E>
docking.widgets.combobox.GhidraComboBox<E>

Type Parameters:
  `E` - the item type

All Implemented Interfaces:
  `GComponent`, `ActionListener`, `ImageObserver`, `ItemSelectable`, `MenuContainer`, `Serializable`, `EventListener`, `Accessible`, `ListDataListener`

public class GhidraComboBox<E> extends JComboBox<E> implements GComponent
GhidraComboBox adds the following features:

1) ActionListeners are only invoked when the <Enter> key is pressed within the text-field of the combo-box. In normal JComboBox case, the ActionListeners are notified when an item is selected from the list.

2) Adds the auto-completion feature. As a user types in the field, the combo box suggest the nearest matching entry in the combo box model. This is enabled by default.

It also fixes the following bug:

A normal JComboBox has a problem (feature?) that if you have a dialog with a button and JComboBox and you edit the comboText field and then hit the button, the button sometimes does not work.

When the combobox loses focus, and its text has changed, it generates an actionPerformed event as though the user pressed <Enter> in the combo text field. This has a bizarre effect if you have added an actionPerformed listener to the combobox and in your callback you adjust the enablement state of the button that you pressed (which caused the text field to lose focus) in that you end up changing the button's internal state(by calling setEnabled(true or false)) in the middle of the button press.

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class javax.swing.JComboBox

  `JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager`

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

  `JComponent.AccessibleJComponent`

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

  `Container.AccessibleAWTContainer`

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

  `Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy`

- ## Field Summary

  ### Fields inherited from class javax.swing.JComboBox

  `actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder`

  ### 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 docking.widgets.GComponent

  `HTML_DISABLE_STRING`

  ### Fields inherited from interface java.awt.image.ImageObserver

  `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GhidraComboBox()`
  Default constructor.
  `GhidraComboBox(E[] items)`
  Construct a new GhidraComboBox and populate a default model with the given items.
  `GhidraComboBox(Collection<E> items)`
  Construct a new GhidraComboBox and populate a default model with the given items.
  `GhidraComboBox(ComboBoxModel<E> model)`
  Construct a new GhidraComboBox using the given model.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addActionListener(ActionListener l)`
  `void`
  `addDocumentListener(DocumentListener l)`
  Adds a document listener to the editor component's document.
  `void`
  `addEditorKeyListener(KeyListener l)`
  Adds a KeyListener to the combobox's editor component.
  `void`
  `addToModel(E item)`
  Adds the given item to the combobox's data model.
  `void`
  `addToModel(Collection<E> items)`
  Adds all the given item to the combobox's data model.
  `void`
  `associateLabel(JLabel label)`
  Convenience method for associating a label with the editor component.
  `void`
  `clearModel()`
  Removes all the items from the combobox data model.
  `boolean`
  `containsItem(E item)`
  Returns true if the combobox contains the given item.
  `String`
  `getText()`
  Returns the text in combobox's editor text component
  `JTextField`
  `getTextField()`
  `void`
  `removeActionListener(ActionListener l)`
  `void`
  `removeDocumentListener(DocumentListener l)`
  Removes a document listener from the editor component's document
  `void`
  `removeEditorKeyListener(KeyListener l)`
  Removes a KeyListener from the combobox's editor component.
  `void`
  `requestFocus()`
  `void`
  `selectAll()`
  Selects the text in the text field editor used by this combo box.
  `void`
  `setAutoCompleteEnabled(boolean enable)`
  This enables or disables auto completion.
  `void`
  `setColumnCount(int columnCount)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  use `setColumns(int)`
  `void`
  `setColumns(int columns)`
  Sets the number of column's in the editor's component (JTextField).
  `void`
  `setDocument(Document document)`
  Sets document to be used by the combobox's editor component.
  `void`
  `setSelectedItem(Object obj)`
  `void`
  `setSelectionEnd(int selectionEnd)`
  Sets the selection end in the editor's text field.
  `void`
  `setSelectionStart(int selectionStart)`
  Sets the selection start in the editor's text field.
  `void`
  `setText(String text)`
  Sets the text on the combobox's editor text component
  `void`
  `setUI(ComboBoxUI ui)`

  ### Methods inherited from class javax.swing.JComboBox

  `actionPerformed, actionPropertyChanged, addItem, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, fireActionEvent, fireItemStateChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyBinding, processKeyEvent, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, showPopup, 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, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, 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`

  ### Methods inherited from interface docking.widgets.GComponent

  `isHTMLRenderingEnabled, setHTMLRenderingEnabled`

- ## Constructor Details

  - ### GhidraComboBox

    public GhidraComboBox()
    Default constructor.

  - ### GhidraComboBox

    public GhidraComboBox(ComboBoxModel<E> model)
    Construct a new GhidraComboBox using the given model.
    Parameters:
      `model` - the model

  - ### GhidraComboBox

    public GhidraComboBox(E[] items)
    Construct a new GhidraComboBox and populate a default model with the given items.
    Parameters:
      `items` - the items

  - ### GhidraComboBox

    public GhidraComboBox(Collection<E> items)
    Construct a new GhidraComboBox and populate a default model with the given items.
    Parameters:
      `items` - the items

- ## Method Details

  - ### setUI

    public void setUI(ComboBoxUI ui)
    Overrides:
      `setUI` in class `JComboBox<E>`

  - ### getText

    public String getText()
    Returns the text in combobox's editor text component
    Returns:
      the text in combobox's editor text component

  - ### setText

    public void setText(String text)
    Sets the text on the combobox's editor text component
    Parameters:
      `text` - the text to set

  - ### setSelectedItem

    public void setSelectedItem(Object obj)
    Overrides:
      `setSelectedItem` in class `JComboBox<E>`

  - ### setColumnCount

    @Deprecated(forRemoval=true, since="11.3") public void setColumnCount(int columnCount)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use `setColumns(int)`
    Sets the size of the text field editor used by this combo box.
    Parameters:
      `columnCount` - The number of columns for the text field editor
    See Also:
      - `JTextField.setColumns(int)`

  - ### setColumns

    public void setColumns(int columns)
    Sets the number of column's in the editor's component (JTextField).
    Parameters:
      `columns` - the number of columns to show
    See Also:
      - `JTextField.setColumns(int)`

  - ### selectAll

    public void selectAll()
    Selects the text in the text field editor used by this combo box.
    See Also:
      - `JTextComponent.selectAll()`

  - ### clearModel

    public void clearModel()
    Removes all the items from the combobox data model.

  - ### addToModel

    public void addToModel(E item)
    Adds the given item to the combobox's data model.
    Parameters:
      `item` - the item to add

  - ### addToModel

    public void addToModel(Collection<E> items)
    Adds all the given item to the combobox's data model.
    Parameters:
      `items` - the item to add

  - ### containsItem

    public boolean containsItem(E item)
    Returns true if the combobox contains the given item.
    Parameters:
      `item` - the item to check
    Returns:
      true if the combobox contains the given item.

  - ### addActionListener

    public void addActionListener(ActionListener l)
    Overrides:
      `addActionListener` in class `JComboBox<E>`

  - ### removeActionListener

    public void removeActionListener(ActionListener l)
    Overrides:
      `removeActionListener` in class `JComboBox<E>`

  - ### addEditorKeyListener

    public void addEditorKeyListener(KeyListener l)
    Adds a KeyListener to the combobox's editor component.
    Parameters:
      `l` - the listener to add

  - ### removeEditorKeyListener

    public void removeEditorKeyListener(KeyListener l)
    Removes a KeyListener from the combobox's editor component.
    Parameters:
      `l` - the listener to remove

  - ### setDocument

    public void setDocument(Document document)
    Sets document to be used by the combobox's editor component.
    Parameters:
      `document` - the document to be set

  - ### addDocumentListener

    public void addDocumentListener(DocumentListener l)
    Adds a document listener to the editor component's document.
    Parameters:
      `l` - the listener to add

  - ### removeDocumentListener

    public void removeDocumentListener(DocumentListener l)
    Removes a document listener from the editor component's document
    Parameters:
      `l` - the listener to remove

  - ### associateLabel

    public void associateLabel(JLabel label)
    Convenience method for associating a label with the editor component.
    Parameters:
      `label` - the label to associate

  - ### setSelectionStart

    public void setSelectionStart(int selectionStart)
    Sets the selection start in the editor's text field.
    Parameters:
      `selectionStart` - the start of the selection
    See Also:
      - `JTextComponent.setSelectionStart(int)`

  - ### setSelectionEnd

    public void setSelectionEnd(int selectionEnd)
    Sets the selection end in the editor's text field.
    Parameters:
      `selectionEnd` - the end of the selection
    See Also:
      - `JTextComponent.setSelectionEnd(int)`

  - ### requestFocus

    public void requestFocus()
    Overrides:
      `requestFocus` in class `JComponent`

  - ### setAutoCompleteEnabled

    public void setAutoCompleteEnabled(boolean enable)
    This enables or disables auto completion. When on, the combobox will attempt to auto-fill the input text box with drop-down items that start with the text entered. This behavior may not be desirable when the drop-down list is more than just a list of previously typed strings. Auto completion is on by default.
    Parameters:
      `enable` - if true, auto completion is on, otherwise it is off.

  - ### getTextField

    public JTextField getTextField()