I've got a little notepad application of my own developed in Java.

I want to register when the file I'm editing in it is modified to warn 
the user about a file modified without saving before
closing the file.

I use a key listener and when I detect a key pressed in my editor I set 
the corresponding variable registering the
modification.

However, there are certain key pulsations that don't modify really the 
file; for example, <CTRL-C>, so when I copy a
piece of text, it's registered a file modification, even if I don't 
paste it there (but in other application).

How can I detect if the key pressed modifies really the text?.  (Or, how 
can I detect if the pressed key is, for example <CTRL-C>?).

Here is my piece of code:

     boolean file_modified = false;
     JTextArea editor = new JTextArea();

     editor.addKeyListener(new KeyAdapter()
     {
           public void keyTyped (KeyEvent e)
           {
               file_modified = true;
           }
        }
     );

_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to