OK. Inserting a component programatically is obvious: myJTextPane.insertComponent.
Accessing components was a little trickier, but I use something like: myJTextPane.getComponents().getComponents()[0]. (1)
But how do I remove a component programatically from myJTextPane?
(1) I am actually programming in Clojure, so the syntax may not be 100%.