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.
For example, JTextArea allows me to specify the Content but doesn't allow setting a custom version of DefaultEditorKit.
Similarly, the JTextPane allows a StyledDocument and forces a StyledEditorKit extending the DefaultEditorKit. I can extend the StyledEditorKit, but can't APPARENTLY override
the static DeletePrevCharAction subclass of DefaultEditorKit.
JEditPane allows (in principle) setting of the EditorKit, however, it forces its own default Document.
Many of the source files contain references to sun classes and SwingUtilities2 that don't seem to be available.
Any suggestions for an editable Swing text area with 1) a specifiable AbstractDocument.Content and 2) a specifiable DefaultEditorKit would be appreciated.
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.