Need simple JTree DnD support

Hi,
I'm developing an app where multiple components are displayed in a central part of a BorderLayout. A JTree with a node per component is shown on the EAST part of the layout. This is basically intended to be an outline (a-la Eclipse) of the content in the central part. I now want to be able to reorganize the components (which are stacked vertically) by dragging and dropping the corresponding outline nodes.
However, I don't want swing to actually modify the tree. I only want to know which node is being dragged, where it's dropped, and the appropriate visual feedback. Having that, I modify the panel containing the components, and my JTree, which is registered as a listener, reacts to that adjusting itself. In particular, I don't want to have to make the user object serializable.
Any suggestion on how to achieve this?

See this well commented example (btw: "serializable" isn't needed):
http://www.java-forum.org/de/userfiles/user3690/TreeDnd.jar
(source code in jar)
The physical transfer is done within the class "NodeMoveTransferHandler".
Each node is moved to the new parent node in "addNodes"
respectively inserted between two nodes in "insertNodes".
Within each of these two methods, the method-calls "removeNodeFromParent"
and "insertNodeInto" are responsible for the transfer.
Thus, you can easily replace them according to your needs.

Similar Messages

  • How do show JTree DnD drop location with custom TreeRenderer?

    I am adding DnD support to a JTree with a custom renderer.
    With the custom renderer I am losing the display of drop location on the tree.
    Is there a method to determine if the passed in node object in the getTreeCellRendererComponent is currently a drop location?
    I can tell if the node is selected, but not if a DnD is in action on the tree.
    Thanks,
    Chris

    Is there a method to determine if the passed in node object in the getTreeCellRendererComponent is currently a drop location?
    I can tell if the node is selected, but not if a DnD is in action on the tree.If you are using Java 1.6 you should be able to do something along these lines:Install a TransferHandler on your tree, and override the method canImport() that takes a TransferHandler.TransferSupport as input argument. That method is called repeatedly during the drag process.
    In that method, ask the passed in TransferSupport for the current drop location, by calling getDropLocation(). For a JTree that will return a JTree.DropLocation, which in turn has methods for finding out which node is the current drop target. Store that node in a variable that your renderer can access.

  • HT1918 I have been trying to update my payment method on my iTunes & Apps store and it won't update, my iPhone 4 and it just keeps telling me that I need to contact iTunes support

    I guess I have more then one Apple ID accounts and I own a little money on both and I am willing to pay and when I try to update and put my new payment method in my iPhone it tells me I need to contact iTunes support, the apple id I'm useing now is xxxxxxx and I know that I had one with xxxxxxx but apple won't let me use that one anymore it just say account nolonger promitted. Please help
    <Edited By Host>

    Have you contacted iTunes support ? If not then you can do so via this page (these are user-to-user forums, and I've asked the hosts to remove your email addresses from your post) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • I have a mac mini mid 2011, this device have; 2,3GHz and 2 Gb Memmory.I want to upgrade the memory and i need the list of supported memory modules

    i have a mac mini mid 2011, this device have; 2,3GHz and 2 Gb Memmory.I want to upgrade the memory and i need the list of supported memory modules. i am from turkey.

    Welcome to Apple Support Communities
    The Mid 2011 Mac mini supports 8 GB of memory officially, but you can install up to 16 GB of RAM, so you can use 2, 4 and 8 GB modules. You can buy more RAM from OWC or Crucial.
    If you are looking for memory at a local shop, make sure you buy 1333 MHz DDR3 memory. See > http://support.apple.com/kb/HT4432?viewlocale=en_US&locale=en_US

  • I am trying to install windows on my mac via bootcamp, and it says I need to download Windows Support Software. I tried, but it says "Download can not continue. The Windows Support Software is not available.

    I am running OSX 10.6.8 Snow lepard I am trying to install windows on my intel imac 20in late 2006  via bootcamp, and it says I need to download Windows Support Software. I tried, but it says "Download can not continue. The Windows Support Software is not available. I bought the Imac secend hand and did not get the install dvd's with it What can I do?

    You don't need to download the Windows support software, because in Snow Leopard, they are only available as a download for the Late 2010 MacBook Air.
    Instead, you have to buy Mac OS X Snow Leopard. The Snow Leopard disc contains the Windows drivers for your Mac, so you have to install them after finishing the Windows installation

  • I NEED OVER ALL HARDWARE SUPPORT FOR PAVILION DV6-3043TX

    I NEED OVER ALL HARDWARE SUPPORT FOR PAVILION DV6-3043TX, DISPLAY : FLASHING, HDD : SMART ERROR 301, KEY BOARD : UNSERVISEABLE, USB PORT : DISCONNECTED CONTINUOUSLY, THERMAL SHUT DOWN : RAPIDLY SHUTDOWN DUE TO INCREASE IN TEMP AS I M PERIODICLY CLEANING VENTS AND USING COOL PAD RECOMENDED BY HP DEALER, CD/DVD DRIVE NOT WORKING PROPERLY. SO I NEED SUPPORT FROM HP. MY EMAIL IS {Personal Information Removed}

    The smart error is usually a fatal hard drive error and it probably needs to be replaced.  Here is a quick scan of this forum for smart error 301:
    http://h30434.www3.hp.com/t5/forums/searchpage/tab/message?filter=location&location=forum-board%3ALa...
    I think the high heat situation and damaged your video chip at the very least and someone will have to open the laptop and reflow, reball or replace the video chip. If this machine is in warrantee, you need to call HP or contact them before it is out of warrantee.
    Reminder: Please select the "Accept as Solution" button on the post that best answers your question. Also, you may click on the white star in the "Kudos" button for any helpful post to give that person a quick thanks. These feedback tools help keep our community active, so you receive better answers faster.

  • HT3775 i need codec format to support audio to play movies?

    i need codec format to support audio to play movies

    Just download the free, open-source media player VLC. It plays pretty much anything.Get VLC here:
    http://www.videolan.org/vlc/download-macosx.html
    Also, beware of dodgy internet sites that say you can't play a movie and offer to install a 'codec' for you. They're typically malware or spyware.

  • Change payment information need to contact itunes support

    I was trying to change my payment information, after all my bill info done, it showed me need to contact itunes support, all the bill information is correct. what should I do? I'm trying to use some in-app purchase. now the in-app purchase is not working. My debit card is working fine.

    Contact iTunes using the link provided. Or, use the contact information found on the Contact Us page, the link to which is at the bottom right of every page.

  • I need help from Customer Support. Whatever this charge is on my credit card,

     He recibido un cargo de su tienda, que curiosamente he visto que se han hecho muchos cargos a diferentes personas bajo el mismo copncepto y tienda.Favor acreditarme dicho monto porque no he comprado nada con ustedes y ni tengo idea donde está Minesota.Este es mi cargo. 23/07/15323343GEEKSQUAD RENE00015826 RICHFIELD UUSRD$1,428.010.00 Y veo en Internet que otros clientes han hecho reclamos del mismo concepto.   Subject Author PostedGEEKSQUAD RENE00015826Care‎03-09-2015 06:30 PMGEEKSQUAD RENE00015826 Unknown ChargePriscillaQ‎12-29-2014 10:08 PMrandom 10 dollar charge from richfield MN to my ac...ChrisBurns‎07-01-2015 12:50 PMUnknown Geeksquad charge on my Credit CardHardingR‎12-01-2014 05:57 PMGeekSquad protection terms changed without being i... Lo que me hace pensar que algo anda muy mal en ese Best Buy.  Como es posible que no hayan corregido e identificado quienes están detrás de este fraude que lleva años. I need help from Customer Support.  Whatever this charge is on my credit card,jesmann‎10-05-2014 04:52 PM  

    Hola scj2000-
    Muchas gracias por visitar nuestro foro en búsqueda de una explicación al cargo que recién apareció en tu tarjeta de crédito.
    Entiendo su preocupación, ya que cualquier cargo extraño que aparece en un estado de cuenta puede ser alarmante. En este caso, el último cargo que puede recuperar usando el correo electrónico que usaste para registrarte al foro, refleja que se renovó un antivirus Kaspersky. Esta autorización nos diste cuando realizaste la compra de tu Lenovo, desde entonces se renueva automáticamente la licencia de antivirus.
    Las otras publicaciones que has leído, indican lo mismo. Un cargo que se ha hecho a la tarjeta de crédito que se presentó durante la compra con la autorización del cliente.
    Lamento mucho la confusión y espero esto aclare tu duda.
    Atentamente,

  • Having trouble downloading form that says I need Traditional Chinese Language Support Package?????

    Having trouble downloading form that says I need Traditional Chinese Language Support Package?????
    I dont know why.  The Adobe site says I need Adobe 9 ???

    Which Adobe product or service is this error message in relation too?  Could you possibly post a screenshot?

  • Hidden objects garden  I try to buy mre gold bars.a message saying I need to contact iTunes support to complete this transaction

    Hidden objects the garden   I buy more gold. Bars in the app. It tells me I need to contact iTunes support to finish this transaction itry to finish in iTunes but no lick. This has been going on for 2 days. I had no problem with. Score  Tuesday 8-7-12

    You should do exactly what it said to do and contact itunes support.

  • Please help .. when entering billing information  its saying i need to contact itunes support about payment review transaction . where can i do this . much appreciated

    please help .. when entering billing information  its saying i need to contact itunes support about payment review transaction . where can i do this . much appreciated

    Contact iTunes using the link provided. Or, use the contact information found on the Contact Us page, the link to which is at the bottom right of every page.

  • Is there an apple approved agreggator that allows me to publish to the iBookstore ibooks created using iBooks author? I would like to use the interactivity that iBooks Author allows but need an aggregator that supports it. Thank you.

    Is there an apple approved agreggator that allows me to publish to the iBookstore ibooks created using iBooks author? I would like to use the interactivity that iBooks Author allows but need an aggregator that supports it. Thank you.

    Apple - iTunes - Partner Programs - Book Publishers
         See a list of Apple-approved aggregators
    Start contacting them with your particular needs and see who fits best.
    Be sure to understand this info:
    Please note that if you choose to work with an aggregator to distribute your content on the iBookstore, Apple's contractual and financial relationship is with that aggregator.

  • HT4009 When I try and make an in app purchase it says it cannot be done and I need to visit apple support on iTunes but nothing any more specific. Please help!

    Please help anyone

    I believe that it's actually telling you that you need to contact Apple support, and if so you will need to do what it says, contact iTunes Support. Go here:
    http://www.apple.com/emea/support/itunes/contact.html
    to contact the iTunes Store.
    Regards.

  • Need simple instructions on transfering photos from Samsung Gusto phone to computer.

    Need simple instructions on transferring photos from Samsung Gusto phone to my PC.

        smcolvin, happy to help with getting those pictures transferred. As the Samsung Gusto does not have the mass storage functionality, this requires a out of the box solution. You can send the pictures as a picture message and place your email address in the "to" field. Open your email inbox on your computer, open the messages and then download the images to the computer (usually right click and "save as").
    Alternatively, you can send the pictures to the online album and access them there. To send to the online album from your phone, press the left soft key. Message>New Message>Picture message. At the "New Picture Msg" screen, press the Right Soft Key and add "To Online Album." Select "Send." On your computer launch your web browser and log into MyVerizon at verizonwireless.com and then go to vzwpix.com .
    BrianP_VZW
    Follow Us on Twitter @VZWSupport

Maybe you are looking for