Class GhidraComboBox<E>
- Type Parameters:
E
- the item type
- All Implemented Interfaces:
GComponent
,ActionListener
,ImageObserver
,ItemSelectable
,MenuContainer
,Serializable
,EventListener
,Accessible
,ListDataListener
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Custom Document to perform matching of items as the user typesNested 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
ConstructorsConstructorDescriptionDefault 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 TypeMethodDescriptionvoid
void
void
addToModel
(E obj) void
addToModel
(Collection<E> items) void
boolean
containsItem
(E obj) getText()
void
void
void
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
(Object obj) 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, 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
getHTMLRenderingEnabled, setHTMLRenderingEnabled
-
Constructor Details
-
GhidraComboBox
public GhidraComboBox()Default constructor. -
GhidraComboBox
Construct a new GhidraComboBox using the given model.- Parameters:
model
- the model
-
GhidraComboBox
Construct a new GhidraComboBox and populate a default model with the given items.- Parameters:
items
- the items
-
GhidraComboBox
Construct a new GhidraComboBox and populate a default model with the given items.- Parameters:
items
- the items
-
-
Method Details
-
setUI
-
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
-
setSelectedItem
- Overrides:
setSelectedItem
in classJComboBox<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:
-
selectAll
public void selectAll() -
clearModel
public void clearModel() -
addToModel
-
addToModel
-
containsItem
-
addActionListener
- Overrides:
addActionListener
in classJComboBox<E>
-
removeActionListener
- Overrides:
removeActionListener
in classJComboBox<E>
-
addDocumentListener
-
removeDocumentListener
-