DocumentListener dl = new MessageDocumentListener();
((AbstractDocument) nboxArea.getDocument()).setDocumentFilter(new DocumentFilter() {
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
string = string.replaceAll("\t", "");
super.insertString(fb, offset, string,(javax.swing.text.AttributeSet) attr);
}
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
text = text.replaceAll("\t", "");
//TODO must do something here
super.replace(fb, offset, length, text,(javax.swing.text.AttributeSet) attrs);
}
});
JTextArea evArea = (JTextArea) c;
evArea.getDocument().removeDocumentListener(dl);
evArea.setText(originalMessage);
इस मामले में मुझे टेक्स्टरेरा में सेट टेक्स्ट के दौरान निम्न त्रुटि मिली। मुझे नहीं पता कि कैसे हल करें।java.lang.IllegalStateException टेक्स्टएरिया में दस्तावेज़ श्रोता का उपयोग करते समय, जावा
Exception in thread "AWT-EventQueue-0"
java.lang.IllegalStateException: Attempt to mutate in notification
मुझे लगता है कि समस्या दस्तावेज़ में पाठ सेट करना या दस्तावेज़ श्रोता में दस्तावेज़ सेट करना है। लेकिन मुझे नहीं पता कि इसे कैसे हल किया जाए। कृपया इस मुद्दे को हल करने में मेरी मदद करें।