How to prevent JScrollPane arrow key handling from moving caret when Scroll Pane wraps Text Pane

前端 未结 2 2006
情书的邮戳
情书的邮戳 2021-01-17 05:23

I have the following requirements:

I need a scrollable JTextPane. The user may type into this text pane, or text may be inserted into it that is not typed by the us

2条回答
  •  萌比男神i
    2021-01-17 05:40

    What if you let user place caret e.g. to let him select and copy some text?

    I would add a DocumentFilter (or override insertString() method of the Document) and in all cases perform insert in the doc.getLength() position and resetting the caret to the doc.getLength() position after the insert.

提交回复
热议问题