I'd like to set the AbstractDocument.Content and a modified DefaultEditorKit into a Swing text area or edit pane for a text/plain document. The idea is to modify a few Actions, such as DeletePrevCharAction in the DefaultEditorKit and have a Content with an external array. I've looked at the sources, but get thwarted at every step.
Although the suggestions worked well, the idea of making a "clean" JTextPane seems unachievable. Here are two problems:
1. ActionEvents pass individual Strings every time a key is typed. While there's a strong hope that these residual one character Strings won't be retained in ordered sequence and will be garbage-collected, there's no avoiding them.
2. The communication between the EditorKit and the Viewer is by Segments. The Viewer provides a Segment to be filled, the Editor assigns a NEW char to the Segment.array, leaving the previous char to be garbage collected. These Segment arrays can be very long. There's no way (that I can see) to clear these Segment.char arrays with random characters BEFORE they go to the Editor. Even if such a cleaning was possible, it might degrade the display performance.
Maybe it's obvious, but I've concluded: Java Swing components will leave sensitive text on your machine.