使用图像拖放 [英] Drag and drop with an image

查看:117
本文介绍了使用图像拖放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在挥杆中创建一个拖放系统,其中被拖动的东西的图像在拖动期间附加到光标上。理论上这可以通过

I need to create a drag and drop system in swing where an image of the thing being dragged is attached to the cursor during the drag. In theory this is achieveable with

public Icon TransferHandler.getVisualRepresentation(Transferable t)

但似乎有一个长期的错误( here )这意味着这个方法从来没有被调用过。我知道我可以通过使用DragSource等实现自己的DnD系统来实现,但是有没有人知道一个更容易的工作环境,可以让我满足我的需要?

but there appears to be a long standing bug (here) that means this method is never called. I know I can do it by implementing my own DnD system with DragSource etc., but does anyone know of an easier workround that will get me what I need?

推荐答案

最后我用旧样式拖放来实现我想要的。然而,我没有理由认为abrightwell的解决方案也不会奏效 - 这只是当时最好的方式。

In the end I used the old style drag-and-drop to implement what I wanted. However I have no reason to think abrightwell's solution wouldn't work just as well - this was just the best way at the time.

这篇关于使用图像拖放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆