I occasionally get an exception in a JTextArea that I’m updating with JTextArea.append() …
java.lang.IllegalArgumentException: Invalid remove at javax.swing.JTextArea.replaceRange(Unknown Source) at sun.plugin.ConsoleWindow$24.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Is there anything that I could be doing wrong that’s causing this exception? The javadoc suggests that the method should be thread-safe.
Documentdoes not provide a rich enough interface to be usefully used in a thread-safe manner.JTextAreawill have some thread-safety claims removed in JDK7. Stick to updating Swing components and Swing text objects in the AWT Event Dispatch Thread (EDT).