• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTree - Have to resort to AWT DnD?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I want to drag a leaf node from a JTree onto a custom component that will generate an image representing that leaf node in the position corresponding to where the drop occurred. By this, I mean I first have a blank workspace, until I drag a node from the tree onto the workspace and it draws an image in the centre of the workspace. I then drag another node to the right of the image currently on the workspace. The insertion point is highlighted by an insertion pointer/line appearing to the right of the current image. After releasing the drop, another image is drawn in the correct position, next to the old image, filling the space appropriately.

This image should hopefully show the kind of thing I want to accomplish:



I also would like to have a representation displayed whilst dragging the node.

A solution to this that may work is to use AWT DnD, utilise the Glass pane to draw the image whilst dragging and then utilise an implementation of DropTargetListener to get the location of the drag and do the insertion point highlighting etc.

I'd like to use the Swing DnD if possible but from looking around, it doesn't seem to offer the power or flexibility to support what I want to do .

Is the AWT solution plausible? Any better solutions?

Thanks,
James


 
Forget Steve. Look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic