public class HexEditorComponent
extends javax.swing.JScrollPane
The hex editor's functionality includes:
javax.swing.JScrollPane.AccessibleJScrollPane, javax.swing.JScrollPane.ScrollBarjavax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROPERTY_ALTERNATE_COLUMN_BG
Property fired when the alternating of column background colors is
toggled.
|
static java.lang.String |
PROPERTY_ALTERNATE_ROW_BG
Property fired when the alternating of row background colors is
toggled.
|
static java.lang.String |
PROPERTY_ASCII_DUMP_HIGHLIGHT_COLOR
Property fired when the highlight color of the ascii dump column
is changed.
|
static java.lang.String |
PROPERTY_HIGHLIGHT_ASCII_DUMP
Property fired when the visibility of the highlight in the "ascii
dump" column is toggled.
|
static java.lang.String |
PROPERTY_PAD_LOW_BYTES
Property fired when the padding of low bytes (
0 - 15)
is toggled. |
static java.lang.String |
PROPERTY_SHOW_GRID
Property fired when the visibility of the grid is toggled.
|
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewportlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTCOLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT| Constructor and Description |
|---|
HexEditorComponent()
Creates a new
HexEditor component. |
| Modifier and Type | Method and Description |
|---|---|
void |
addHexEditorListener(HexEditorListener l)
Adds a hex editor listener to this editor.
|
void |
addSelectionChangedListener(SelectionChangedListener l)
Registers a prospect who is interested when the text selection from the
hex editor becomes changed.
|
int |
cellToOffset(int row,
int col)
Returns the offset into the bytes being edited represented at the
specified cell in the table, if any.
|
void |
copy()
Copies the currently selected bytes to the clipboard.
|
void |
cut()
Removes the currently selected bytes and moves them to the clipboard.
|
void |
delete()
Removes the currently selected bytes.
|
protected void |
fireHexEditorEvent(int offset,
int added,
int removed)
Notifies all interested listeners of an event in this hex editor.
|
boolean |
getAlternateColumnBG()
Returns whether the color of columns in the hex editor should alternate.
|
boolean |
getAlternateRowBG()
Returns whether the color of rows in the hex editor should alternate.
|
byte |
getByte(int offset)
Returns the byte at the specified offset.
|
int |
getByteCount()
Returns the number of bytes being edited.
|
byte[] |
getBytes() |
boolean |
getHighlightSelectionInAsciiDump()
Returns whether the selected bytes should also appear selected in
the "ascii dump" column.
|
java.awt.Color |
getHighlightSelectionInAsciiDumpColor()
Returns the color used to highlight the selected bytes in the
"ascii dump" column.
|
int |
getLargestSelectionIndex()
Returns the largest selection index.
|
boolean |
getPadLowBytes()
Returns whether bytes that can be displayed as a single char
(i.e.
|
int |
getSmallestSelectionIndex()
Returns the smallest selection index.
|
java.awt.Point |
offsetToCell(int offset)
Returns the cell representing the specified offset into the hex
document.
|
void |
open(java.io.InputStream in)
Sets the contents in the hex editor to the contents of the specified
input stream.
|
void |
open(java.lang.String fileName)
Sets the contents in the hex editor to the contents of the specified
file.
|
void |
paste()
"Pastes" the bytes in the clipboard into the current selection in
the hex editor.
|
boolean |
redo()
Tries to redo the last action undone.
|
void |
removeBytes(int offs,
int len)
Removes a range of bytes.
|
void |
removeHexEditorListener(HexEditorListener l)
Removes the specified hex editor listener from this editor.
|
void |
removeSelectionChangedListener(SelectionChangedListener l)
Removes a listener who isn't any longer interested whether the text
selection from the hex editor becomes changed.
|
void |
replaceBytes(int offset,
int len,
byte[] bytes)
Replaces a range of bytes.
|
void |
replaceSelection(byte[] bytes)
Replaces the currently selected bytes (if greater or equal to 1) with the specified
new bytes.
|
void |
setAlternateColumnBG(boolean alternate)
Sets whether the column color should alternate in the hex editor.
|
void |
setAlternateRowBG(boolean alternate)
Sets whether the row color should alternate in the hex editor.
|
void |
setCellEditable(boolean cellEditable)
Toggles whether the cells in the hex editor are editable by clicking
in them.
|
void |
setHighlightSelectionInAsciiDump(boolean highlight)
Sets whether the selected bytes should also appear selected in the
"ascii dump" column.
|
void |
setHighlightSelectionInAsciiDumpColor(java.awt.Color c)
Sets what color should be used for the "ascii dump" selection.
|
void |
setPadLowBytes(boolean pad)
Sets whether bytes that can be displayed as a single char
(i.e.
|
void |
setSelectedRange(int startOffs,
int endOffs)
Sets the range of bytes to select in the hex editor.
|
void |
setShowColumnHeader(boolean show)
Toggles whether table's column header is visible.
|
void |
setShowGrid(boolean show)
Toggles whether the table's grid lines are visible.
|
void |
setShowRowHeader(boolean show)
Toggles whether table's row header is visible.
|
boolean |
undo()
Tries to undo the last action.
|
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled, updateUIaddAncestorListener, 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, 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, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, 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, transferFocusDownCycle, validate, validateTreeaction, 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, getPeer, 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, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final java.lang.String PROPERTY_ALTERNATE_COLUMN_BG
public static final java.lang.String PROPERTY_ALTERNATE_ROW_BG
public static final java.lang.String PROPERTY_ASCII_DUMP_HIGHLIGHT_COLOR
public static final java.lang.String PROPERTY_HIGHLIGHT_ASCII_DUMP
public static final java.lang.String PROPERTY_PAD_LOW_BYTES
0 - 15)
is toggled.public static final java.lang.String PROPERTY_SHOW_GRID
public HexEditorComponent()
HexEditor component.public void addHexEditorListener(HexEditorListener l)
l - The listener to add.removeHexEditorListener(HexEditorListener)public void addSelectionChangedListener(SelectionChangedListener l)
l - The concerning listener.removeSelectionChangedListener(SelectionChangedListener)public int cellToOffset(int row,
int col)
row - The row in the table.col - The column in the table.-1 if the
cell does not represent part of the byte array (such as the
tailing "ascii dump" column's cells).offsetToCell(int)public void copy()
public void cut()
protected void fireHexEditorEvent(int offset,
int added,
int removed)
offset - The offset of the change.added - The number of bytes added.removed - The number of bytes removed.public boolean getAlternateColumnBG()
setAlternateColumnBG(boolean),
getAlternateRowBG()public boolean getAlternateRowBG()
setAlternateRowBG(boolean),
getAlternateColumnBG()public byte getByte(int offset)
offset - The offset.public int getByteCount()
public byte[] getBytes()
public boolean getHighlightSelectionInAsciiDump()
setHighlightSelectionInAsciiDump(boolean)public java.awt.Color getHighlightSelectionInAsciiDumpColor()
setHighlightSelectionInAsciiDumpColor(Color),
getHighlightSelectionInAsciiDump()public int getLargestSelectionIndex()
getSmallestSelectionIndex()public boolean getPadLowBytes()
0 - 15) are prepended with a "0"
char to make them two characters wide in the display.0" in the display.setPadLowBytes(boolean)public int getSmallestSelectionIndex()
getLargestSelectionIndex()public java.awt.Point offsetToCell(int offset)
offset - The offset into the document.(row, col). If the
specified offset is invalid, (-1, -1) is returned.cellToOffset(int, int)public void open(java.lang.String fileName)
throws java.io.IOException
fileName - The name of the file to open.java.io.IOException - If an IO error occurs.public void open(java.io.InputStream in)
throws java.io.IOException
in - An input stream.java.io.IOException - If an IO error occurs.public void paste()
public boolean redo()
undo()public void removeBytes(int offs,
int len)
offs - The offset of the range of bytes to remove.len - The number of bytes to remove.replaceBytes(int, int, byte[])public void removeHexEditorListener(HexEditorListener l)
l - The listener to remove.addHexEditorListener(HexEditorListener)public void removeSelectionChangedListener(SelectionChangedListener l)
l - The concerning previous prospect.addSelectionChangedListener(SelectionChangedListener)public void replaceBytes(int offset,
int len,
byte[] bytes)
offset - The offset of the range of bytes to replace.len - The number of bytes to replace.bytes - The bytes to replace the range with.removeBytes(int, int),
replaceSelection(byte[])public void replaceSelection(byte[] bytes)
bytes - The new bytes. If this is null or an empty
array, calling this method simply removes the currently
selected bytes.replaceBytes(int, int, byte[])public void setAlternateColumnBG(boolean alternate)
PROPERTY_ALTERNATE_COLUMN_BG.alternate - Whether the column color should alternate.getAlternateColumnBG(),
setAlternateRowBG(boolean)public void setAlternateRowBG(boolean alternate)
PROPERTY_ALTERNATE_ROW_BG.alternate - Whether the row color should alternate.getAlternateRowBG(),
setAlternateColumnBG(boolean)public void setCellEditable(boolean cellEditable)
cellEditable - Whether individual editor cells should be editable.public void setHighlightSelectionInAsciiDump(boolean highlight)
PROPERTY_HIGHLIGHT_ASCII_DUMP.highlight - Whether the selected bytes should also appear
selected in the "ascii dump" column.getHighlightSelectionInAsciiDump(),
setHighlightSelectionInAsciiDumpColor(Color)public void setHighlightSelectionInAsciiDumpColor(java.awt.Color c)
PROPERTY_ASCII_DUMP_HIGHLIGHT_COLOR.c - The color to use.getHighlightSelectionInAsciiDumpColor(),
setHighlightSelectionInAsciiDump(boolean)public void setPadLowBytes(boolean pad)
0 - 15) are prepended with a "0"
char to make them two characters wide in the display. This method
fires a property change event of type PROPERTY_PAD_LOW_BYTES.pad - Whether to pad such bytes in the display.getPadLowBytes()public void setSelectedRange(int startOffs,
int endOffs)
startOffs - The first byte to select.endOffs - The last byte to select.public void setShowColumnHeader(boolean show)
show - Whether to show the table column header.setShowRowHeader(boolean)public void setShowGrid(boolean show)
PROPERTY_SHOW_GRID.show - Whether grid lines are visible.public void setShowRowHeader(boolean show)
show - Whether to show the table row header.setShowColumnHeader(boolean)public boolean undo()
redo()