Package ghidra.app.util

# Class AddressInput

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ghidra.app.util.AddressInput

All Implemented Interfaces:
  `FocusableEditor`, `ImageObserver`, `MenuContainer`, `Serializable`, `Accessible`

public class AddressInput extends JPanel implements FocusableEditor
Panel for user input of addresses. Handles case with multiple address spaces.

See Also:
  - Serialized Form

- ## Nested Class Summary

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

  `JPanel.AccessibleJPanel`

  ## 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
  Modifier and Type
  Field
  Description
  `static final Predicate<AddressSpace>`
  `INCLUDE_ALL_MEMORY_SPACES`
  Address Space predicate which includes all memory spaces, including the `AddressSpace.OTHER_SPACE` and all overlay spaces.
  `static final Predicate<AddressSpace>`
  `INCLUDE_LOADED_MEMORY_SPACES`
  Address Space predicate which includes all loaded memory spaces.

  ### 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
  `AddressInput()`
  Constructor for AddressInput.
  `AddressInput(Border border)`
  Constructor for AddressInput.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addActionListener(ActionListener listener)`
  Add an action listener that will be notified anytime the user presses the return key while in the text field.
  `void`
  `addChangeListener(ChangeListener listener)`
  Adds a change listener that will be notified anytime this address value in this panel changes
  `void`
  `clear()`
  Clear the offset part of the address field.
  `boolean`
  `containsAddressSpaces()`
  `void`
  `focusEditor()`
  Called with the editor should take focus.
  `Address`
  `getAddress()`
  Returns the address in the field or null if the address can't be parsed.
  `AddressFactory`
  `getAddressFactory()`
  `AddressSpace`
  `getAddressSpace()`
  Returns the address space selected in the combobox or in the input text itself if specified (eg: "register:1").
  `protected JTextField`
  `getAddressSpaceTextField()`
  `protected JTextField`
  `getAddressTextField()`
  `String`
  `getText()`
  Returns the text in this field.
  `String`
  `getValue()`
  Get the offset part of the address field.
  `boolean`
  `hasInput()`
  Returns true if the Address input field contains text.
  `boolean`
  `isEditable()`
  `boolean`
  `isEnabled()`
  `void`
  `removeActionListener(ActionListener listener)`
  Removes the action listener from the list to be notified.
  `void`
  `requestFocus()`
  `void`
  `select()`
  Select the text field that is the offset.
  `void`
  `selectDefaultAddressSpace()`
  Sets the selected combo box item to the default address space.
  `void`
  `setAddress(Address addr)`
  Set the field to display the given address
  `void`
  `setAddressFactory(AddressFactory factory)`
  Set the address factory to be used to parse addresses.
  `void`
  `setAddressFactory(AddressFactory factory, Predicate<AddressSpace> predicate)`
  Set the address factory to be used to parse addresses.
  `void`
  `setAddressSpaceEditable(boolean state)`
  Set the address space (if it is shown) such that it is not editable.
  `void`
  `setEditable(boolean state)`
  Set the text field to be editable according to the state param.
  `void`
  `setEnabled(boolean enabled)`
  `void`
  `setValue(Address addr)`
  Set the address space and offset.
  `void`
  `setValue(String value)`
  Set the offset part of the address offset field without changing address space.
  `void`
  `showAddressSpaceCombo(boolean showCombo)`

  ### 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, 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, 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 Details

  - ### INCLUDE_LOADED_MEMORY_SPACES

    public static final Predicate<AddressSpace> INCLUDE_LOADED_MEMORY_SPACES
    Address Space predicate which includes all loaded memory spaces. See `AddressSpace.isLoadedMemorySpace()`. Intended for use with `setAddressFactory(AddressFactory, Predicate)`.

  - ### INCLUDE_ALL_MEMORY_SPACES

    public static final Predicate<AddressSpace> INCLUDE_ALL_MEMORY_SPACES
    Address Space predicate which includes all memory spaces, including the `AddressSpace.OTHER_SPACE` and all overlay spaces. Intended for use with `setAddressFactory(AddressFactory, Predicate)`.

- ## Constructor Details

  - ### AddressInput

    public AddressInput(Border border)
    Constructor for AddressInput.
    Parameters:
      `border` - border around each subcomponent (combo/text fields).

  - ### AddressInput

    public AddressInput()
    Constructor for AddressInput.

- ## Method Details

  - ### setAddress

    public void setAddress(Address addr)
    Set the field to display the given address

  - ### getAddress

    public Address getAddress()
    Returns the address in the field or null if the address can't be parsed.
    Returns:
      The address for the current value in the text field
    Throws:
      `NullPointerException` - if AddressFactory has not been set.

  - ### getAddressSpace

    public AddressSpace getAddressSpace()
    Returns the address space selected in the combobox or in the input text itself if specified (eg: "register:1"). If the address space is not specified; returns the default space.
    Throws:
      `NullPointerException` - if AddressFactory has not been set.

  - ### hasInput

    public boolean hasInput()
    Returns true if the Address input field contains text. The getAddress() method will return null if text is not a valid address.

  - ### getText

    public String getText()
    Returns the text in this field.
    Returns:
      the text in this field

  - ### getAddressFactory

    public AddressFactory getAddressFactory()

  - ### setAddressFactory

    public void setAddressFactory(AddressFactory factory)
    Set the address factory to be used to parse addresses. Also used to set the combo box with the list of valid address spaces if there is more than one space. Only loaded memory spaces will be allowed (see `AddressSpace.isLoadedMemorySpace()`).
    Parameters:
      `factory` - address factory to use

  - ### setAddressFactory

    public void setAddressFactory(AddressFactory factory, Predicate<AddressSpace> predicate)
    Set the address factory to be used to parse addresses. Also used to set the combo box with the list of valid address spaces if there is more than one space. The specified predicate will be used to determine if an address space should be included.
    Parameters:
      `factory` - address factory to use
      `predicate` - callback used to determine if an address space should be included for selection

  - ### selectDefaultAddressSpace

    public void selectDefaultAddressSpace()
    Sets the selected combo box item to the default address space.

  - ### clear

    public void clear()
    Clear the offset part of the address field.

  - ### select

    public void select()
    Select the text field that is the offset.

  - ### getValue

    public String getValue()
    Get the offset part of the address field.
    Returns:
      String

  - ### setValue

    public void setValue(String value)
    Set the offset part of the address offset field without changing address space. NOTE: This method is intended for test use only and mimicks user input.
    Parameters:
      `value` - the offset value string

  - ### setValue

    public void setValue(Address addr)
    Set the address space and offset. NOTE: Unlike `setAddress(Address)` this method is intended for test use only and mimicks user input with `stateChanged()` notification.
    Parameters:
      `addr` - the address value

  - ### isEnabled

    public boolean isEnabled()
    Overrides:
      `isEnabled` in class `Component`

  - ### containsAddressSpaces

    public boolean containsAddressSpaces()

  - ### setAddressSpaceEditable

    public void setAddressSpaceEditable(boolean state)
    Set the address space (if it is shown) such that it is not editable. If the combo box is shown for multiple address spaces, then the combo box is replaced with a fixed uneditable text field that shows the currently selected address space.
    Parameters:
      `state` - false means that the combo box should not be editable

  - ### addChangeListener

    public void addChangeListener(ChangeListener listener)
    Adds a change listener that will be notified anytime this address value in this panel changes
    Parameters:
      `listener` - the change listener to be notified.

  - ### addActionListener

    public void addActionListener(ActionListener listener)
    Add an action listener that will be notified anytime the user presses the return key while in the text field.
    Parameters:
      `listener` - the action listener to be notified.

  - ### removeActionListener

    public void removeActionListener(ActionListener listener)
    Removes the action listener from the list to be notified.
    Parameters:
      `listener` -

  - ### setEnabled

    public void setEnabled(boolean enabled)
    Overrides:
      `setEnabled` in class `JComponent`
    See Also:
      - `Component.setEnabled(boolean)`

  - ### setEditable

    public void setEditable(boolean state)
    Set the text field to be editable according to the state param.

  - ### isEditable

    public boolean isEditable()

  - ### focusEditor

    public void focusEditor()
    Description copied from interface: `FocusableEditor`
    Called with the editor should take focus.
    Specified by:
      `focusEditor` in interface `FocusableEditor`

  - ### showAddressSpaceCombo

    public void showAddressSpaceCombo(boolean showCombo)

  - ### requestFocus

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

  - ### getAddressTextField

    protected JTextField getAddressTextField()

  - ### getAddressSpaceTextField

    protected JTextField getAddressSpaceTextField()