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.
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:
getrowstart(...)
getrowend(...)
using these values can text document
using gettext(...)
method.
Comments
Post a Comment