JtextEditorPane - How to prevent copy and paste from wrapping text in html paragraph tags?
问题 I have: HTMLDocument document = new HTMLDocument(); JTextPane htmlEditorPane = new JTextPane(document) htmlEditorPane.setContentType("text/html"); I then select some text in the middle of a sentence and call (wrapped in the appropriate ActionListeners): htmlEditorPane.copy(); htmlEditorPane.paste(); For whatever reason whenever I do this the text that is copy and pasted is wrapped in <p> tags. How can I keep all the formatting but the <p> tags that seem to be added? 回答1: Use