Reputation: 1592
I have I JTextPane
and I'm using DefaultStyledDocument
as a text model. I currenly use the JTextPane
's default copy()
and paste()
methods for copying and pasting, but as you know they copy/paste plain text only. I need to be able to copy styled text from a browser for example, and paste it in the JTextPane
preserving the styles.
Does anyone know how I can achieve this?
Upvotes: 1
Views: 1715
Reputation: 57421
When content in clipboard has representation which can be processed by the installed EditorKit then JTextPane automatically recognize the content and process the content updating Document accordingly.
E.g. if you set RTFEditorKit and paste content copied from MS Word (which has text/rtf flavor) the content will be processed correctly.
Upvotes: 0