• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in two listener??????  RSS feed

 
alok shukla
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
the problem arises due to two listener first one is Document Listener and another is the Caret Lisstenet, i used Caret listenet to treet my coded special characters "<<APS100>>" as a single character when i click in between then the
cursor goes to the end of <<APS100>> but problem arises in two case
1> when i select one or number of char then i recieved Stack Over Flow Exception and it goes in the caret listener function.
2> when i delete characters <<APS100>> from left or right then in one key stroke i have to delete whole <<APS100>>. for this i take two string one store left of the <<APS100>> and second contains the right of the <<APS100>> now i concatenate these two and set this in the text Area .i wrte this code in the remove update of document listener .problem arises when i am going to set the concatinated string in text area then it throws the Exception like that



java.lang.IllegalStateException: Attempt to mutate in notification
at javax.swing.text.AbstractDocument.writeLock(Unknown Source)
at javax.swing.text.AbstractDocument.replace(Unknown Source)
at javax.swing.text.JTextComponent.setText(Unknown Source)
at com.apsiva.swclient.elementeditor.ui.SplitViewController.fun1(SplitViewControll er.java:187)
at com.apsiva.swclient.elementeditor.ui.SplitViewController.documentDeleted(SplitV iewController.java:182)

plz help in this problem
thanks
alok
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception 'java.lang.IllegalStateException: Attempt to mutate in notification' is a result of violating the constraint given in the last line of the DocumentListener api: the document listener must not alter the event source, ie, the document.

I would expect trouble with the CaretListener if you are constraining it and then making selections with the mouse. I would try to bind a KeyStroke to the component with an Action in which you do the deletion/concatenation if the cursor is located between the '<< >>' glyphs.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!