开发者

Send accelerator with mouse to perform selection of text

开发者 https://www.devze.com 2023-04-09 23:56 出处:网络
I need to make selection of text using mouse instead of ctrl+开发者_如何学PythonA I tried: sendAcceleratorKey(MouseEvent.BUTTON1, \"\");

I need to make selection of text using mouse instead of ctrl+开发者_如何学PythonA I tried:

sendAcceleratorKey(MouseEvent.BUTTON1, "");

but I don't know which argument could I set to say make a click with mouse and let the mouse enforced to select the text.


If the text is in a JTextComponent, selectAll() may be a suitable choice in your MouseListener.

Addendum: You may also be able to leverage the select-all Action, which is bound to control-A or meta-A by default on various platforms.

Your sscce may be helpful in deciding. There's a related example here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号