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 t开发者_Go百科he form name@emailid.com. To select the entire text would require triple clicks. I want the email to be selected in a single click. Is this possible?
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?
精彩评论