by robert » Tue Jul 05, 2011 11:07 pm
Hi Golana,
The easiest way to do this is to add a javax.swing.event.DocumentListener to the editor's Document, and add the "*" to the displayed file name when the document is modified. Remove it whenever it is saved.
You can also use the org.fife.ui.rsyntaxtextarea.
TextEditorPane class, that comes standard in the library. It has a "dirty" flag that is set/cleared properly when you edit/save/reload the file. You can also query it directly via the isDirty() method. Note that you'll still have to add the DocumentListener though to know when it's first made dirty.
From its documentation:
An extension of RSyntaxTextArea that adds information about the file being edited, such as:
Its name and location.
Is it dirty?
Is it read-only?
The last time it was loaded or saved to disk (local files only).
The file's encoding on disk.
Easy access to the line separator.
Loading and saving is also built into the editor.
Both local and remote files (e.g. ftp) are supported. See the FileLocation class for more information.
Hi Golana,
The easiest way to do this is to add a javax.swing.event.DocumentListener to the editor's Document, and add the "*" to the displayed file name when the document is modified. Remove it whenever it is saved.
You can also use the org.fife.ui.rsyntaxtextarea.[url=http://javadoc.fifesoft.com/rsyntaxtextarea/org/fife/ui/rsyntaxtextarea/TextEditorPane.html]TextEditorPane[/url] class, that comes standard in the library. It has a "dirty" flag that is set/cleared properly when you edit/save/reload the file. You can also query it directly via the isDirty() method. Note that you'll still have to add the DocumentListener though to know when it's first made dirty.
From its documentation:
[quote]
An extension of RSyntaxTextArea that adds information about the file being edited, such as:
Its name and location.
Is it dirty?
Is it read-only?
The last time it was loaded or saved to disk (local files only).
The file's encoding on disk.
Easy access to the line separator.
Loading and saving is also built into the editor.
Both local and remote files (e.g. ftp) are supported. See the FileLocation class for more information.
[/quote]