Java Swing JTextPane in intellij framework



I'm creating a Pycharm Plugin with a simple JTextPane (plain text). If I paste (CTRL+V) a multi-line text into it, it always pastes it into a single line replacing any type of EOL to spaces. Also the keys HOME or END jump to the start or the end of the document, not start/end of a current line. Is there a way to set some property that this behavior changes?

If I use the JTextPane outside the intellij framework, everything works as expected. Do I need to change something in the EditorKit properties?


Hi Miloslav,

It's hard to tell what is the reason. Is there any chance to share the project sources?

Also, depending on your use case, please consider using Editor Component.


Hi Karol,

I originally wanted to use the EditorTextField, because of the code completion. But the problem is, I need custom TransferHandler to drag&drop custom data. If I use setTransferHandler on the EditorTextField, nothing happens. Is there a way to implement my own Transfer handler and my own copy/paste actions?


I would try to implement com.intellij.ide.PasteProvider.

You can check the example implementation that pastes Markdown markup when a file is dropped on the editor:


Hi Karol great, the paste function works perfect now.


But how about the drag-feature from the EditorTextField? Pycharm Editors have the drag feature - the text is cut and pasted. In my EditorText Field the dragging does not work. How do I do the dragging text from my editor somewhere else, which would perform copy. That is, it keeps the source content intact.