Drag and Drop from JTree to JTextArea

D

dado0583

Hey, I'm looking to create a drag and drop function from a JTree to the
JTextArea. I want to be able to drag a node into the text area, and
then the name of that node is dropped into the text area.

I've looked at the JavaWorld tutorial on drag and dropping and the Java
Sun tutorial. However, the Java Sun tutorial doesnt go into enough
depth and I feel a little out of depth with the JavaWorld tutorial.

Can anyone suggest a suitable tutorial? Or if there is ust a few lines
of code, could you show me what I would need to do?

Cheers,
David
 
D

dado0583

Hey, I've managed to implement a basic DND between a JTree and a
JTextArea.

I have created a DragSource and associated it with the JTree, and a
DropTarget associated with the JTextArea. I have written the drop
method to insert the string at the current Caret Position, but
unfortunately, the caret position is not updated as the mouse moves
around the JTextArea.

What I want to know is how to track what position in the JTextArea, the
mouse is hovering over? I've tried a CaretListener, but as expected it
did not work. I'm guessing I may need some kind of mouse listener, any
ideas?

Cheers,
David
 

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
473,780
Messages
2,569,611
Members
45,274
Latest member
JessMcMast

Latest Threads

Top