Drag and Drop in Java - Painting more than just a border

风流意气都作罢 提交于 2019-12-13 04:17:50

问题


I have a JTable and a JList and I have my code set up so that I can drag from the JTable to the JList using built in Swing methods.

When I drag from the JTable to the JList, the "image" that is dragged is simply a border of the thing I am dragging. Specifically, in the case of the source being a JTable, the image is just a border of the row I selected to drag.

How can I override what this "image" is? How can I get it so that the user can drag text, not just a border (rectangle)?


回答1:


You could check out

  • http://rabbit-hole.blogspot.com.au/2006/05/my-drag-image-is-better-than-yours.html
  • http://rabbit-hole.blogspot.com.au/2006/08/drop-target-navigation-or-you-drag.html
  • http://rabbit-hole.blogspot.com.au/2006/04/smooth-jlist-drop-target-animation.html
  • http://rabbit-hole.blogspot.com.au/2006/07/drag-images-for-everyoneand-we-do-mean.html

Now some may not be quite what you after, but he's done so much with drag n drop, it'd be waste note to check out as much as you can




回答2:


You may be able to take advantage of Drop Location Rendering to achieve the desired effect. If you are already doing so, please edit your question to include an sscce that exhibits any problems you encounter. This example may be helpful.



来源:https://stackoverflow.com/questions/11424859/drag-and-drop-in-java-painting-more-than-just-a-border

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!