Drag and drop question

R

Rhino

I've been looking at the drag and drop tutorial at
http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html. I want to be
sure that I'm reading it correctly.

Am I right in understanding that it is possible to add drag and drop support
to _any_ JComponent or, presumably, subclass of JComponent, even if that
component is not in the chart near the beginning of that tutorial?

Basically, I am trying to set up a drag and drop of foreground or background
colors from one JPanel to another. I'm also trying to ensure that it is
possible for this transfer to be two-way. Let me explain.

I have a simple GUI where the user needs to select 3 different colors from a
pool of distinct colors. Each of the three selected colors is supposed to
fill a specific role, such as a Frame color or a foreground text color. I
want the user to select the color for each role by dragging a color from the
pool, where each color is represented by a small square JPanel, into a
different small JPanel that is associated with the role of the color.

Furthermore, if the user wants to change the color associated with the role,
I want them to put the color for that role back into the pool by dragging it
back there, then choosing a different color of the pool. Also, if the user
wants a color that has been selected for one role to be used for a different
role instead, I want the user to be able to drag the color from one role's
JPanel to the other role's JPanel. In each case, when I drag a color from
the pool to a role, from one role to another role, or from a role back to
the pool, I want the color to be moved, not copied. This ensures that I
don't get two roles with the same color or have the same color in the pool
twice.

I'm having a bit of trouble getting the code working so I just want to make
sure that what I'm doing is possible in the first place.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top