Solved

Swing Question (Drag and Drop??)

Posted on 2001-06-12
9
228 Views
Last Modified: 2013-12-14
I'm wondering if anyone could tell me (a) if the following is possible in swing and (b) if so, how you'd implement it please ! :)

I'm wondering if I could have the following situation,
a JFrame that contains 2 scroll panes,
One on the left, one on the right.
In each scroll pane there is a JTree.
I'd like to create the visual "mapping" between nodes of these two seperate trees. I.E. You click on a node in the left jtree, and drag a line to a another node in the right jtree. When you "let go" a line permenantly appears between the 2 nodes in the 2 different trees. Can this be done ??? the drawing of lines between 2 seperate components ?? Personally, I don't think it can be done in swing at the moment, but ppl around me are saying "yeah java drag and drop can do that" without giving me any details :) Sun's drag and drop tutorial is not written yet - and the javaworld one mentions nothing like the behaviour I've described above.

Any opinions/insights ????

Also as a side note ...... The default behaviour of a jtree is that it expands left-to-right, can you change it so that it expands right-to-left ??? ie "backwards".

any help/opinions greatly appreciated,
thanks,
SD
0
Comment
Question by:somadude
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 200 total points
Comment Utility
I think for the line drawing you will have to use the classpane on your main window

try having a look at:

http://www.cs.biu.ac.il/home/computing/manuals/program/Java/Tutorial/uiswing/components/rootpane.html

and

http://web2.java.sun.com/products/jfc/tsc/articles/containers/

Is quite a nice page for explanation...

Now drag and drop...  try

http://www.javaworld.com/javaworld/javatips/jw-javatip97.html

and

http://www.cs.unr.edu/~sushil/work/java/dnd/

Hope this helps...  Sorry I havent really supplied you with any code, but these links should explain stuff better than I could...

One thing to watch out for drag and drop...  It seems to work differently on Linux/Solaris/Windows (Linux bein the worst) so you might need to do a bit of tweaking and have access to all these systems to ensure it works fully :-)

Have fun!!

Good Luck!!

Tim.
0
 

Expert Comment

by:msmsm
Comment Utility
Hi ,
I have a word document write by a university teacher.
Maybe that could be useful to you.

Please e-mail me (silviu@tisp.ro)for sending this to you.

Silviu
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
Instead of posting this as an answer, wouldn't it have been best posting a comment?  Also, this doesn't help anyone in the future who buys this question...

Could you post the most important points/code as a comment?

Tim.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
msmsm,

Have a look at the ee guidlines for comments and answers, and then have a good hard look at your 'proposed answer'.
If you have an answer then post it, otherwise ...
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:somadude
Comment Utility
Well no sign of the word doc, so for now it's more a comment than answer, cheers.
0
 

Expert Comment

by:msmsm
Comment Utility
Sorry for posting like answer.
My fault. In the future will not happend again.
Sorry again.

Silviu


0
 
LVL 92

Expert Comment

by:objects
Comment Utility
Apology accepted :)
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
From me too :-)
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[points to TimYates]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now