e640. 使一个组件可拖动
2024-08-27 23:31:54
This example demonstrates the code needed to make a component draggable. The object being transferred in this example is a string.
public class DraggableComponent extends JComponent
implements DragGestureListener, DragSourceListener {
DragSource dragSource; public DraggableComponent() {
dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer(
this, DnDConstants.ACTION_COPY_OR_MOVE, this);
}
public void dragGestureRecognized(DragGestureEvent evt) {
Transferable t = new StringSelection("aString");
dragSource.startDrag (evt, DragSource.DefaultCopyDrop, t, this);
}
public void dragEnter(DragSourceDragEvent evt) {
// Called when the user is dragging this drag source and enters
// the drop target.
}
public void dragOver(DragSourceDragEvent evt) {
// Called when the user is dragging this drag source and moves
// over the drop target.
}
public void dragExit(DragSourceEvent evt) {
// Called when the user is dragging this drag source and leaves
// the drop target.
}
public void dropActionChanged(DragSourceDragEvent evt) {
// Called when the user changes the drag action between copy or move.
}
public void dragDropEnd(DragSourceDropEvent evt) {
// Called when the user finishes or cancels the drag operation.
}
}
Related Examples |
最新文章
- MySQL,MariaDB:Undo | Redo [转]
- WPF 画心2.0版之元旦快乐
- NSOprationQueue 与 GCD 的区别与选用
- Windows程序设再读笔记00-序言
- 把页面上的图表导出为pdf文件,分享一种请求下载文件的方法
- SQL作业的操作全
- 深入理解ASP.NET的内部运行机制(转)
- Windows下安装破解JIRA6.3.6
- SQL Server DAC 管理员专用连接
- QTableWidget 用法总结(只能使用标准的数据模型,并且其单元格数据是QTableWidgetItem的对象)
- stata
- [Unity Asset]AssetBundle系列——游戏资源打包
- 微信小程序之----底部菜单action-sheet
- .Net Core MVC 过滤器(一)
- Pycon 2017: Python可视化库大全
- RPM基础知识
- JS小练习1
- 基本的socket编程的介绍
- 认识EasyUI——DataGrid的onClickRow事件
- Bootstrap3基础 caret 辅助类样式 下拉的小三角