This is a runtime error, which still can occur even if your code compiles with no errors.
The Javadocs for the insert
method state:
Throws:
IllegalArgumentException - if pos is an invalid position in the model
Your position words * charsa
must not exist in your JTextArea
(yet). Either ensure that the position is already there or modify your formula for the position so it refers to an existing position.