DnD
来源:互联网 发布:电脑上看淘宝直播回放 编辑:程序博客网 时间:2024/05/16 17:10
要把一个桌面上的文件拉进JAVA应用程序,显示文件路径,不容易啊~~
GOOGLE了不少,看了毫无头绪,还是看别人的实例比较好~
二个关键地方:
1.允许谁来接受DROP事件
自java.awt.Component以下都有setDropTarget(DropTarget)方法
实例DropTarget
DropTarget(Component c, DropTargetListener dtl)
这个C就是那个谁
DTL是由谁来处理DnD事件,可以自己写个类来实现此接口
2.处理DROP事件
实现DropTargetListener的类须实现以下5个方法:
dragEnter(DropTargetDragEvent dtde)
当DRAG进入C的Rectangle时的事件处理
dragExit(DropTargetEvent dte)
当DRAG退出C的Rectangle时的事件处理
dragOver(DropTargetDragEvent dtde)
Called when a drag operation is ongoing, while the mouse pointer is still over the operable part of the drop site for the DropTarget
registered with this listener.
当DRAG不在C的Rectangle时事件处理
drop(DropTargetDropEvent dtde)
当DROP动作完成,就是松开鼠标的时候的事件处理.
我的显示文件路径什么的就写在这里.
dropActionChanged(DropTargetDragEvent dtde)
Called if the user has modified the current drop gestur.
老实说,我不知道这个方法有什么用.
请高手指点.
另外关于第一点,我找到好二个方法都有相同效果:
1.Component.setDropTarget(DropTarget)
2.直接NEW 一个DropTarget
打完收功~
- DnD
- SWT DND
- dojo dnd
- java里的dnd
- DND入门学习
- DND入门学习
- java里的dnd
- react-dnd helloworld
- DnD on Listbox in C#
- 用dojo.dnd实现拖放功能
- 小谈java dnd 拖放机制
- Dojo Dnd - 拖拽功能实战
- java中使用拖拽功能DND
- GWT 拖拽做象棋 (1). dnd 学习.
- easyui的dnd插件实现datagrid行拖拽
- qt dnd drag and drop 拖放
- DND是如何封装WinSock的?
- SWT下实现Drag and Drop(DND)学习笔记(写作中...)
- Game Lobby!
- Linux调度器(schedule函数)
- 在资源中修改类型库路径
- THE LONG TAIL--尾巴上的火把
- 工作了 该如何生活
- DnD
- 安装OpenCV
- Unlimited Rapidshare Downloads
- MySpace Exploit found By Smokey & MX
- 由内到外设计----带给用户真正的价值
- 遇上携手网,仿如梅兰芳走上了属于他的戏台
- 堆排序(java)
- Linux local root
- JAVA在线自测题系统,测试版上线,欢迎测试和提供题目