1

I need to make selection of text using mouse instead of ctrl+A 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.

lola
  • 5,649
  • 11
  • 49
  • 61
  • 1
    I have no idea what the `sendAcceleratorKey` method is since it is not part of the (JDK6) API. There is no method that I know of that will drag the mouse from the beginning of the text component to the end of the text component. What is the point of this? – camickr Sep 29 '11 at 14:57

1 Answers1

1

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.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • it is a textArea , and I want to make the selection on first displayed text using mouse, how could I use selectAll ? – lola Sep 30 '11 at 07:19
  • There are related examples [here](http://stackoverflow.com/questions/1178312/how-to-select-all-text-in-a-jformattedtextfield-when-it-gets-focus). – trashgod Sep 30 '11 at 14:33