e640. 使一个组件可拖动
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 |
e640. 使一个组件可拖动的更多相关文章
- e641. 使一个组件成为拖放目标
public class DropTargetComponent extends JComponent implements DropTargetListener { public DropTarge ...
- Android在代码中使用布局文件中的一个组件
使用前必须要把组件与其父组件的关系断开,比如有一个组件的名称为scrollChildLayout,则可以使用下面的代码进行分离 ((ViewGroup)scrollChildLayout.getPar ...
- 使一个div始终显示在页面中间
使一个div始终显示在页面中间 假设我们有一个div层:<div id=”myDiv”></div> 首先,我们用css来控制它在水平上始终居中,那么我们的css代码应该是这样 ...
- ITextSharp用来生成 PDF 的一个组件
iTextSharp 是用来生成 PDF 的一个组件,在 1998 年夏天的时候,Bruno Lowagie ,iText 的创作者,参与了学校的一个项目,当时使用 HTML 来生成报告,但是,使用 ...
- QT UI 使一个QWidget里面的元素自动填充满本QWidget
使一个QWidget里面的元素自动填充满本QWidget: 对象查看器,右键点击本QWidget,选择"布局",为此QWidget增加一个布局. 如果该QWidget只有一个对象, ...
- extjs每一个组件要设置唯一的ID
extjs每一个组件要设置唯一的ID,否则会造成各种错误 EXTJS基本上是靠ID来识别组件的,假如你在panel1中有个ID:"keyword"的textfield,而panel ...
- 【JAVASCRIPT】React学习-如何构建一个组件
摘要 react 学习包括几个部分: 文本渲染 JSX 语法 组件化思想 数据流 组件化思想 组件就是 UI + UI 交互逻辑,组件有三个常规map , 分别为state 状态 . props 数据 ...
- 微信小程序开发03-这是一个组件
编写组件 基本结构 接上文:微信小程序开发02-小程序基本介绍 我们今天先来实现这个弹出层: 之前这个组件是一个容器类组件,弹出层可设置载入的html结构,然后再设置各种事件即可,这种组件有一个特点: ...
- Vue.js教程--基础(实例 模版语法template computed, watch v-if, v-show v-for, 一个组件的v-for.)
官网:https://cn.vuejs.org/v2/guide/index.html Vue.js 的核心是一个允许采用简洁的模板语法来声明式地将数据渲染进 DOM 的系统. 视频教程:https: ...
随机推荐
- ubuntu为python处理图片安装图片数据增强库imgaug
1 依赖Required dependencies: six numpy scipy scikit-image (pip install -U scikit-image) OpenCV (i.e. c ...
- 在CentOS 7上安装Node.js的4种方法(yum安装和源码安装)
CentOS 7上的安装方法,其中涵盖了源码安装,已编译版本安装,EPEL(Extra Packages for Enterprise Linux)安装和通过NVM(Node version mana ...
- cocos2dx实现3d拾取注意事项
用的是cocos2dx 3.x,如果是真机测试,glview = cocos2d::GLViewImpl::createWithRect(...)和glview->setDesignResolu ...
- Linode中的Network Helper
Linode主机vps有一个很好的网络配置工具:Network Helper,他可以在系统启动的时候,根据你的操作系统,以及检测到的网络配置等信息,自动配置好网络,非常有用. 官方文档: Networ ...
- linux 2.6.xx自动加载kvm模块
在文件夹/etc/udev/rules.d/中添加文件65-kvm.rules,文件内容如下: KERNEL=="kvm", MODE="0660", GROU ...
- Python 2.7.9 Demo - 020.函数的定义、返回
#coding=utf-8 #!/usr/bin/python def setConfig(): hello = 'world'; print 'The value has been setted.' ...
- 一:cocos2dx 3.2 尚不支持cubeMap?二:光照需要shader实现
一: cocos2dx 3.2 尚不支持cubeMap? 因为需要调用cocos2dx 封装的bindTexture的方法,发现只能绑定2DTexture,对Cube_Map无能无力.顿感累觉不爱…… ...
- Ubuntu12.04下tomcat的安装与配置
1.下载tomcat 我的tomcat是从 http://tomcat.apache.org/download-70.cgi 这里下载的tar.gz版本的. 2.解压tomcat $sudo tar ...
- grails3.1.5 com.mysql.jdbc.Driver
[报错] Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1 ...
- weblogic检查项
日常维护中,weblogic检查的几个项: 1.JVM: 如最大堆内存.最小堆内存. 2.GC回收: 查看jvm空闲内存变化情况,每次GC的回收情况:控制台可以强制垃圾回收,看看回收内存是否太小,如果 ...