Drag and Drop issue in Jlist - Transferhandler not working

Hi all,
I have a problem associated with the drag and drop of components into a Jlist.
When I drag component out of a Jlist, the control reaches inside transfer handler, but when I try to insert a component into the Jlist, the control does not reach inside Jlist transfer handler.
This is the piece of my code.

>>     jlist.setDropMode(DropMode.INSERT);
     jlist.setDragEnabled(true);
     jlist.setTransferHandler(new TransferHandler()
            {
          
                  List fileList;
                  boolean export = false;
                  List<File> newList = null;
                  
                  protected Transferable createTransferable(JComponent c)
                  {
                        System.out.println("inside handler");
                                ..............................
                                ..............................


Please help me with this issue.
Any help in this regard will be well appreciated with points.
Regards,
Sreejith
Sreejith22Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TrigunaCommented:
You can choose either one of them.
>>     jlist.setDropMode(DropMode.INSERT);
     jlist.setDragEnabled(true);

If you want items to be dragged out of JList then enable the drag.
If you want items to be dopped into JList then use the DropMode.

Hope this helps.
Sreejith22Author Commented:
>>If you want items to be dragged out of JList then enable the drag.
If you want items to be dopped into JList then use the DropMode.


What if I want both?
TrigunaCommented:
This is how it works.

When you drag, createTransferable, canImport is called. And when you drop it, ImportData, canImport, exportDone is called.
If you are implementing everything then you have to override all the methods which are required.
As soon as you hold an item, createTransferable of that component Transferable is called and hence you are getting inside that block.

You can implement everything without a problem. But I didnt find a reason for single JList to implement both drag and drop together.
TrigunaCommented:
canImport is called recurrsively until you leave the hold item.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.