如何在 Jtextarea 中选择一行?
我有一个不可编辑的 jtextarea。里面有一些文字。我想要的是,当用户单击 jtextarea(最好是单击)时,整行都会突出显示,并检索该突出显示的文本。
每行实际上都有一个格式为 [email protected] 的电子邮件。要选择整个文本需要三次单击。我希望单击一下即可选择电子邮件。这可能吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然。只需实现您自己的侦听器并调用 http://java.sun.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#select%28int,%20int%29。
但是 JList 不是不太适合您的要求吗?
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?