views:

150

answers:

1

Hello everyone,

I have a jtextarea that is not editable. It has some text in it. What i want is that when a user clicks in the jtextarea, (preferably single click), the entire line be highlighted, and this highlighted text be retrieved.

Each line actually has an email of the form [email protected]. To select the entire text would require triple clicks. I want the email to be selected in a single click. Is this possible?

+2  A: 

Sure. Just implement you own listener and call http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#select%28int,%20int%29 on the JTextArea.

But wouldn't a JList not rather fit your requirements?

Searles
Damn. Just didnt realise that java had a JList!
mithun1538