Reputation: 353
I want to generate a clickable event from text area which contains a list of names of people. When we click on a certain name it must make a call to a method (which in turn is going to display the details of that person from a XML file).
Is this possible with text area? I have heard about JTextPane
, but I need some other option.
Upvotes: 0
Views: 622
Reputation: 57381
Yes it's possible. Use viewToModel()
method to get offset for the clicked point. Then use Utilities
to getWordStart/getWordEnd
methods to get the clicked name. Then just pass the name into desired function.
Upvotes: 4