Class GhidraComboBox<E>

  • All Implemented Interfaces:
    GComponent, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ListDataListener

    public class GhidraComboBox<E>
    extends javax.swing.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. 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 
      Modifier and Type Class Description
      class  GhidraComboBox.InterceptedInputDocument
      Custom Document the valid user input on the fly.
      • Nested classes/interfaces inherited from class javax.swing.JComboBox

        javax.swing.JComboBox.AccessibleJComboBox, javax.swing.JComboBox.KeySelectionManager
      • 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 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 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​(java.util.Vector<E> items)
      Construct a new GhidraComboBox and populate a default model with the given Vector of items.
      GhidraComboBox​(javax.swing.ComboBoxModel<E> aModel)
      Construct a new GhidraComboBox using the given model.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addActionListener​(java.awt.event.ActionListener l)  
      void addDocumentListener​(javax.swing.event.DocumentListener l)  
      void addToModel​(E obj)  
      void clearModel()
      Remove all entries in the drop down list
      boolean containsItem​(E obj)  
      java.lang.String getText()  
      void removeActionListener​(java.awt.event.ActionListener l)  
      void removeDocumentListener​(javax.swing.event.DocumentListener l)  
      void selectAll()  
      void setColumnCount​(int columnCount)
      Sets the size of the text field editor used by this combo box, if that is the type of editor used.
      void setEnterKeyForwarding​(boolean forwardEnter)
      HACK ALERT: By default, the JComboBoxUI forwards the <Enter> key actions to the root pane of the JComboBox's container (which is used primarily by any installed 'default button').
      void setSelectedItem​(java.lang.Object obj)  
      void setUI​(javax.swing.plaf.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, 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
    • Constructor Detail

      • GhidraComboBox

        public GhidraComboBox()
        Default constructor.
      • GhidraComboBox

        public GhidraComboBox​(javax.swing.ComboBoxModel<E> aModel)
        Construct a new GhidraComboBox using the given model.
        See Also:
        JComboBox(ComboBoxModel)
      • GhidraComboBox

        public GhidraComboBox​(E[] items)
        Construct a new GhidraComboBox and populate a default model with the given items.
        See Also:
        JComboBox(Object[])
      • GhidraComboBox

        public GhidraComboBox​(java.util.Vector<E> items)
        Construct a new GhidraComboBox and populate a default model with the given Vector of items.
        See Also:
        JComboBox(Vector)
    • Method Detail

      • setUI

        public void setUI​(javax.swing.plaf.ComboBoxUI ui)
        Overrides:
        setUI in class javax.swing.JComboBox<E>
      • setEnterKeyForwarding

        public void setEnterKeyForwarding​(boolean forwardEnter)
        HACK ALERT: By default, the JComboBoxUI forwards the <Enter> key actions to the root pane of the JComboBox's container (which is used primarily by any installed 'default button'). The problem is that the forwarding does not happen always. In the case that the <Enter> key will trigger a selection in the combo box, the action is NOT forwarded.

        By default Ghidra disables the forwarding altogether, since most users of GhidraComboBox will add an action listener to handle <Enter> actions.

        To re-enable the default behavior, set the forwardEnter value to true.

        Parameters:
        forwardEnter - true to enable default <Enter> key handling.
      • getText

        public java.lang.String getText()
      • setSelectedItem

        public void setSelectedItem​(java.lang.Object obj)
        Overrides:
        setSelectedItem in class javax.swing.JComboBox<E>
      • setColumnCount

        public void setColumnCount​(int columnCount)
        Sets the size of the text field editor used by this combo box, if that is the type of editor used. By default the editor for combo boxes is a text field. This method is a convenience for the user to set the number of columns on that text field, which updates the preferred size of the combo box.
        Parameters:
        columnCount - The number of columns for the text field editor
        See Also:
        JTextField.setColumns(int)
      • selectAll

        public void selectAll()
      • clearModel

        public void clearModel()
        Remove all entries in the drop down list
      • addToModel

        public void addToModel​(E obj)
      • containsItem

        public boolean containsItem​(E obj)
      • addActionListener

        public void addActionListener​(java.awt.event.ActionListener l)
        Overrides:
        addActionListener in class javax.swing.JComboBox<E>
      • removeActionListener

        public void removeActionListener​(java.awt.event.ActionListener l)
        Overrides:
        removeActionListener in class javax.swing.JComboBox<E>
      • addDocumentListener

        public void addDocumentListener​(javax.swing.event.DocumentListener l)
      • removeDocumentListener

        public void removeDocumentListener​(javax.swing.event.DocumentListener l)