Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2006

Tip: Looking for answers? Try searching our database.

drag and drop - JTree and JList

Thread view: 
mario@data.pl - 08 Sep 2006 16:07 GMT
Does anyone have example of drag nad drop between JList and JTree? I
would like to take some entry in list and drop in into one leaf on
tree. The result is some message - I don't want to change anything in
tree.

I've doing it for some days and I have no idea to get it working. Can
anybody help me with it?

thanks in advance
Mariusz
Michael Rauscher - 11 Sep 2006 23:15 GMT
mario@data.pl schrieb:
> Does anyone have example of drag nad drop between JList and JTree? I
> would like to take some entry in list and drop in into one leaf on
> tree. The result is some message - I don't want to change anything in
> tree.

Have a look at here

http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html#complex

Bye
Michael
mario - 12 Sep 2006 08:51 GMT
> http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html#complex

I've looked there. It wasn't useful for me in my case :(

Mariusz
Michael Rauscher - 12 Sep 2006 09:47 GMT
mario schrieb:
>> http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html#complex
>
> I've looked there. It wasn't useful for me in my case :(

I found it very useful for your case.

But where did you get stuck in your implementation?

Bye
Michael
mario - 12 Sep 2006 13:16 GMT
> But where did you get stuck in your implementation?

I have to know on which leaf am I trying to drop and I don't know how to
get it. I'm trying to add mouse listener on target of dropping ( in
canimport() method) but it does not work. The main goal which I want to
make is changing a cursor when it is over the leaf where dropping is
disabled. I can recognize if I've dropped on right leaf or the not
allowed leaf. But it is done after dropping and I want to know it before
dropping - change of cursors should inform user where dropping is
allowed or not.

Tutorial with jlist to jlist drag and drop is useful, I inserted instead
of one list my jtree but I can't do thing I've written above. Drag and
drop without that works.

Is it clear for you what I want to make? Have you and idea how to do it?
I suppose it should be something connected with ability to get info
about path in tree while mouse is over choosen leaf, not after it has
been clicked

Mariusz
Michael Rauscher - 12 Sep 2006 17:40 GMT
mario schrieb:

>> But where did you get stuck in your implementation?
>
[quoted text clipped - 6 lines]
> dropping - change of cursors should inform user where dropping is
> allowed or not.

You can use a DropTargetListener for this.

Bye
Michael
mario - 13 Sep 2006 08:35 GMT
> You can use a DropTargetListener for this.

OK, DropTargetListener does what I wrote in last post. But there is
another problem: when I'm over particular leaf, where dropping is
disabled (disabled because I don't want user to drop there)
I want cursor to change. At the moment I'm able to change setDragEnabled
for whole tree, not in any moment. Is it possible to do? For some parts
of tree disabel dropping... I can get the path on tree on which I'm
while mouse is over tree but I don't know how to use it.

Mariusz
Michael Rauscher - 13 Sep 2006 13:44 GMT
mario schrieb:
>> You can use a DropTargetListener for this.
>
[quoted text clipped - 5 lines]
> of tree disabel dropping... I can get the path on tree on which I'm
> while mouse is over tree but I don't know how to use it.

You've just to call e.rejectDrag() or e.acceptDrag() where e ist the
DropTargetDragEvent.

Bye
Michael
mario - 13 Sep 2006 14:33 GMT
> You've just to call e.rejectDrag() or e.acceptDrag() where e ist the
> DropTargetDragEvent.

Thank you very much! It works :)

Mariusz


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.