I'm a seasoned Java developer, but I am brand new when it comes to the GUI libraries JavaFX and Swing. I would like to use JavaFX since it seems to be the new way to go, but I'm having trouble determining if there are existing classes that meet my needs.
For my application, I need to load a file and then display its contents as hex in something like a read-only TextArea where the user can scroll through the file and select text with the mouse and perform actions on the selected text. It'll be something similar to a hex editor like HxD. The files can be really large (on the order of gigs), so I cannot load the entire file and place it in the text area, but I want to pretend that it is. This means I need control of the scrollbar in order to make it look like the entire file is loaded and to keep the position when I swap out text in the text area. I also need the ability to select or highlight various pieces of text at the same time (for example, all instances of a specific word). The user can also change the view of the text (for example, showing 16 bytes worth of text per line or inserting a newline after a specific byte value).
JavaFX's TextArea cannot highlight all instances of a word. I also cannot control the scrolling within it.
WebView could be an option if I can control the min and max values and the position of the scrollbar. Is controlling the scrollbar possible? Of course then I would have to deal with the nastiness of building HTML strings for it.
I thought about TextFlow, but the user cannot select text with the TextFlow and Text objects.
I tried TableView and ListView, but setting up the observable lists and cell factories seem like more work than what it's worth.
I even tried setting up a GridPane with a bunch of TextFields, but that proved cumbersome and the performance was terrible.
Is there anything within JavaFX (or even Swing) that I can use or do I have to resort to writing my own custom TextArea class?
After another week of researching, I'm coming to the conclusion that there isn't anything in JavaFX or Swing that meets all my needs. Using Swing's JTextArea, the user can select text with the mouse and I can highlight text using the highlighter, but I am unable to control the scrolling in JScrollPane. The ability to customize the scroll bar is lacking. JScrollPane provides a nice layout, but it automatically resets the scroll bar values to match the current view of the JTextArea, which would only contain a page or two of the file at a time. I may have to write my own version of JScrollPane or maybe the UI for it. Any thoughts?