Java - Scroll to specific text inside JTextArea

前端 未结 4 2107
生来不讨喜
生来不讨喜 2020-11-27 07:51

I\'m trying to implement a feature inside the current program that I\'m writing and I wanna learn how to scroll down to specific text inside a JTextArea. For example, lets s

4条回答
  •  醉梦人生
    2020-11-27 08:32

    First get the text you set in the text area and build an index using a map to hold the character and the position you find it on.

    Based on this the previous answer suggested used the setCaretPosition using the value retrieved from the map.

提交回复
热议问题