Carey Brown wrote:JTextArea can't do this. JTextArea has setText() and getText() methods for accessing the text. It's up to you to connect those to file reading and writing methods, and perhaps to add an ActionListener to detect when the text in the pane is modified.
JTextArea, like any JTextComponent, is backed by a Document. That's an interface, so it should be possible to write a Document implementation that does what's needed. Alternatively, the Document can have a DocumentListener added to it. A third way is to use a DocumentFilter and attach that to an AbstractDocument. I'd go for the latter myself.
However, it's going to be tricky to support edits in the middle of the document or deletes without writing the entire document (or large portions of it) for every update.