How to get selected text values in a textarea by mouse click?
Hi Everyone,
What I am trying to do is to click on some texts in a textarea, then get the selected text value.
If you guys have used an accounting software called Simply Accounting, you might understand better.
I list all my customer names in a textarea. What I want is, when I click on one customer, another GUI pops up with this customer's information. My problem is that I don't know how to get the selected text value from a textarea.
Could anyone give a hand here? Thank you in advance.
[527 byte] By [
windmovesa] at [2007-11-26 14:52:15]

> Is there some reason you aren't using a JList or
> JTable to display
> the user names/information?
Thank you for es5f2000's reply. You just gave me a better idea! There is not a particular reason I have to use TextArea to list my customers. As long as the component can make my idea alive, I definitely use it. Still, if there is any way to get a selected text value, it will help me a lot with my project. Thank you.
As mentioned earlier, it really does sound like you want a JList at the very least (or a JTable, or a JComboBox).But, you can always call myTextArea.getSelectedText(), and go from there.
> As mentioned earlier, it really does sound like you
> want a JList at the very least (or a JTable, or a
> JComboBox).
>
> But, you can always call
> myTextArea.getSelectedText(), and go from there.
Oh! Thanks Pal, that's what I wanted to know! I wonder how I missed reading this API document! Thank you again.