JTextArea - get the position that the user drops a drag on

D

dado0583

Hi, basically this is what I want to do:

The user drags something from another component and drops it
somewhere in the JTextArea. I want to know the position in the area
that the drop was made. (Preferably getting the caret position).

As you hover over the JTextArea, the caret position remains unaffected.
Is there anyway to use a MouseListener or some type of mechanism to
figure out where in the document the click was dropped?

Cheers,
David
 
D

dado0583

Hi, has anyone any insights into this question, as I still do not have
a solution.

PS. The droptarget component can be a JTextPane or something similar
and not neccessarily a JTextArea
 
D

dado0583

Hi,
I managed to solve the problem. Using an example from the Sun
Tutorials I have managed to accomplish my goal.

It seems that I was trying to over complicate things. All it needed was
a custom TransferHandler class, and to dragEnable both components
involved in the transfer.

Cheers anyway tho
 
A

Andrew Thompson

I managed to solve the problem. ..(snip solution)

Excellent, glad you sorted it. Thanks for reporting success
and the solution, for the archives.
 
D

Dj Frenzy

No problem, it irritates me when I find an old question without a
solution, and I'm sure it annoys other people too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top