java - Set mouse click event on text? -


i have project random text displayed in jscrollpane. text coded in , not editable. there way create mouse click event on each line of text , have event take text clicked on , have display in textfield?

the part stumps me how act on line of text versus clickevent on button per se. below rendering of project , areas containing text.

enter image description here

presumably text displayed in jtextarea or jtextpane, add mouselistener component. when mouseevent generated can caret position. using caret position can use utilities class. has methods like:

  1. getrowstart(...)
  2. getrowend(...)

using these values can text document using gettext(...) method.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -