You consider it as a symbol in a certain position:
myJTextPane.getDocument().remove(int offs, int len)
For example, if you have a text panel with components in the following order:
[Component1] - [Component2] - [Component3] - text
and you want to remove the second and third components:
myJTextPane.getDocument().remove(1, 2)
See documentation
source
share