How to remove a component from JTextPane

OK Box software component obvious: myJTextPane.insertComponent.

Access to the components was a little harder, but I use something like: myJTextPane.getComponents().getComponents()[0]. (1)

But how can I remove a component programmatically from myJTextPane?

(1) I really program in Clojure, so the syntax may not be 100%.

0
source share
1 answer

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

+3
source

All Articles