HexLib - A Java component by sample

Features

What are the main features of HexLib?

From an endusers perspective the answer will differ from the perspective of a developer. The main reason I see is the different interest about the  usage. Most of the features an end user is interested might interest as well a developer, but not necessarily. The given list below tries to cover both interest, and therefore might contain details an end user would expect anyway, but the developer not.
The main reason why I address especially the developer is that the HexEditor is build on a Java component (named HexLib). HexLibs provides  a Java library and could be used in other programs as well. Feel free to reuse it. All coded functions are demonstrated in the HexEditor.

Some of the functions are for the GUI only and are the main purpose to demonstrate that some fancy user interaction has not its limitations in Java .

Functions resp. Features
Details
Function implemented in
Display Display the content of a File in Hex- and ASCII-View
(and the matching file size)
Library
Content is changeable resp. could be set to not editable
File size is displayed and can be switched between
  • Bytes only
  • automatic conversion into Bytes/KBytes/MBytes
Filesize as Bytes
Filesize converted into MB
Recognize changes and mark them in the header of the Hex part Filechange indicator
Amount of digits in border  (resp. indication of  location) either dynamic to content or fixed 
Colors
  • Stripe colors
  • Background of  Hex- and ASCII-View are changeable
  • Colors for border  (resp. indication of  location) are changeable
  • Colors of the inactive parts (at Hex-View, left corner, and when pane is larger then the component, e.g. too few bytes to display)
Library
File management Complete File management, i.e. New File supported and  Open, Save, Save As with huge files benefit from a Progessbar GUI
File-Size up to 2 GB are supported under specific restrictions
  1. You have that amount of memory free
  2. Have 64bit Java installed (on 32-bit Windows the limitation is 1.4-1.6GB)
  3. Have set the increased Heap-parameter in the command-line option (e.g. -Xmx 1.2GB)
I have tested with a 905MB-file loading without any problems. Editing and viewing was no problem at all. File with 905MB
Increase the file-size which can be loaded with the command-line option (e.g. -Xmx 1200MB)
e.g. java -jar HexEditor.jar -Xmx 1200MB
File name will be filled in automatically as you type in
  • Names are selected  with cursor-keys  resp. PgDn/PgUp
  • ENTER loads the file
  • Ctrl-Space displays the selection
Autofiller for input
Management if file-content does not fit into memory (cause it is too large)
Search
  • by ASCII-String
    • case sensitive
    • case insensitive
  • by Hex-String
  • forward or backward
  • starts with a specific position (negative, like -1, or number greater then file size are interpreted as the begin of file)
  • found position is displayed
Library
Keyboard Control
  • Cursor Left/Right/Up/Down
  • Page Up/Down
  • Home/End
  • Ctrl-Home/Ctrl-End
Library
Selection
Text can be selected with Keyboard or  Mouse:

Keyboard
  • Shift and Arrow-Keys, PgUp/PgDn, Pos1/End expand the selection automatically
Mouse
  • Click anywhere and hold the mouse till the end
  • Click anywhere, release the mouse, move somewhere else, hold the Shift-Key and Press left-mouse to extend the selection
  • Hold the Ctrl-Key and press anywhere. If you have already selected a text, the cursor will be displayed and you can once again extend the selection as above
Multiple Selection of text 'Get'
As soon as you place somewhere the cursor, without any additional selection (described above), the selection will be reseted.
Library
Search
You can highlight all matching text parts at once Mark All checkbox
GUI
Cursor
  • current position of the cursor displayed
  • jump to a specific position (if out of range, then either first or last is used)
  • Blink rate changeable
  • Cursor is marked in the selection to have a better orientation for the user (see  screenshot for Selection)
Library and GUI
Panel
Expandable Panels to save space on GUI  - i.e. panel content could be hided if not required Expandable Panel
GUI
Font
Resize and reset of the font Font resize
GUI
Heap View
  • displays currently used Heap
  • displays currently used Total Memory
  • could launch the Java Garbage Collector to free unused memory (to do so, double click the Heap View)
HeapView
GUI