How can I determine which character was deleted from a JTextArea by the 'Delete' or 'Backspace' keys?

Sandip Chitale

JTextArea is a 'view' on javax.swing.text.PlainDocument. The PlainDocument class supports registration of javax.swing.event.DocumentListener. Thus you could register a DocumentListener and in the

public void removeUpdate(DocumentEvent e)

call back figure out what is being deleted.

ALternatively you could install an alternate keymap whereby you intercept the 'Delete' and 'Backspace' key.

Please look at -

classes, methods and fields.
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.