本文整理汇总了Java中java.awt.dnd.DragSource.createDefaultDragGestureRecognizer方法的典型用法代码示例。如果您正苦于以下问题:Java DragSource.createDefaultDragGestureRecognizer方法的具体用法?Java DragSource.createDefaultDragGestureRecognizer怎么用?Java DragSource.createDefaultDragGestureRecognizer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.dnd.DragSource
的用法示例。
在下文中一共展示了DragSource.createDefaultDragGestureRecognizer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Frame sourceFrame = createFrame("Source Frame", 0, 0);
Frame targetFrame = createFrame("Target Frame", 250, 250);
DragSource defaultDragSource
= DragSource.getDefaultDragSource();
defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame,
DnDConstants.ACTION_COPY_OR_MOVE,
new TestDragGestureListener());
new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE,
new TestDropTargetListener(targetFrame));
Robot robot = new Robot();
robot.setAutoDelay(50);
sourceFrame.toFront();
robot.waitForIdle();
Point point = getCenterPoint(sourceFrame);
robot.mouseMove(point.x, point.y);
robot.waitForIdle();
mouseDragAndDrop(robot, point, getCenterPoint(targetFrame));
long time = System.currentTimeMillis() + 200;
while (!passed) {
if (time < System.currentTimeMillis()) {
sourceFrame.dispose();
targetFrame.dispose();
throw new RuntimeException("Mouse clicked event is lost!");
}
Thread.sleep(10);
}
sourceFrame.dispose();
targetFrame.dispose();
}
示例2: DragManager
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/** Creates a new instance of SplashDnDSupport */
DragManager(JComponent component) {
this.component = component;
dSource = new DragSource();
dRecognizer = dSource.createDefaultDragGestureRecognizer(this.component,DnDConstants.ACTION_MOVE,this);
dTarget = new DropTarget(this.component,DnDConstants.ACTION_MOVE,this);
component.addMouseMotionListener(this);
oCursor = component.getCursor();
}
示例3: IndexedDragSource
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/** Creates drag source with asociated list where drag
* will take place.
* Also creates the default gesture and asociates this with
* given component */
IndexedDragSource(JList comp) {
this.comp = comp;
// initialize gesture
DragSource ds = DragSource.getDefaultDragSource();
ds.createDefaultDragGestureRecognizer(comp, DnDConstants.ACTION_MOVE, this);
}
示例4: installDragGestureHandler
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/**
*
*/
protected void installDragGestureHandler() {
DragGestureListener dragGestureListener = new DragGestureListener() {
public void dragGestureRecognized(DragGestureEvent e) {
if (graphComponent.isDragEnabled() && first != null) {
final TransferHandler th = graphComponent.getTransferHandler();
if (th instanceof mxGraphTransferHandler) {
final mxGraphTransferable t = (mxGraphTransferable) ((mxGraphTransferHandler) th)
.createTransferable(graphComponent);
if (t != null) {
e.startDrag(null, mxSwingConstants.EMPTY_IMAGE, new Point(), t,
new DragSourceAdapter() {
/**
*
*/
public void dragDropEnd(DragSourceDropEvent dsde) {
((mxGraphTransferHandler) th).exportDone(graphComponent, t,
TransferHandler.NONE);
first = null;
}
});
}
}
}
}
};
DragSource dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer(graphComponent.getGraphControl(),
(isCloneEnabled()) ? DnDConstants.ACTION_COPY_OR_MOVE : DnDConstants.ACTION_MOVE,
dragGestureListener);
}
示例5: SourcePanel
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public SourcePanel () {
setPreferredSize(new Dimension(200, 200));
DragSource defaultDragSource =
DragSource.getDefaultDragSource();
defaultDragSource.createDefaultDragGestureRecognizer(this,
DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
setBackground(Color.RED);
}
示例6: SourcePanel
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public SourcePanel() {
setPreferredSize(new Dimension(200, 200));
DragSource defaultDragSource =
DragSource.getDefaultDragSource();
defaultDragSource.createDefaultDragGestureRecognizer(this,
DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
setBackground(Color.RED);
}
示例7: DragSourceButton
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public DragSourceButton(String str) {
super(str);
DragSource ds = DragSource.getDefaultDragSource();
ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY,
this);
}
示例8: runTest
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
private static void runTest() throws Exception {
Frame sourceFrame = createFrame("Source Frame", 100, 100);
Frame targetFrame = createFrame("Target Frame", 350, 350);
DragSource defaultDragSource
= DragSource.getDefaultDragSource();
defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame,
DnDConstants.ACTION_COPY_OR_MOVE,
new TestDragGestureListener());
new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE,
new TestDropTargetListener(targetFrame));
Robot robot = new Robot();
robot.setAutoDelay(50);
sourceFrame.toFront();
robot.waitForIdle();
Point point = getCenterPoint(sourceFrame);
robot.mouseMove(point.x, point.y);
robot.waitForIdle();
mouseDragAndDrop(robot, point, getCenterPoint(targetFrame));
long time = System.currentTimeMillis() + 1000;
while (!passed) {
if (time < System.currentTimeMillis()) {
sourceFrame.dispose();
targetFrame.dispose();
throw new RuntimeException("Mouse clicked event is lost!");
}
Thread.sleep(10);
}
sourceFrame.dispose();
targetFrame.dispose();
}
示例9: TreeTransferHandler
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
protected TreeTransferHandler(JTree tree, JTreeDragController controller, int action, boolean drawIcon) {
this.tree = tree;
this.controller = controller;
drawImage = drawIcon;
dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer(tree, action, this);
}
示例10: initRepositoryViewer
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
private void initRepositoryViewer(){
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
DragSource ds = new DragSource();
ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY,
new RepositoryViewerDragGestureListener());
}
示例11: installDragGestureHandler
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/**
*
*/
protected void installDragGestureHandler()
{
DragGestureListener dragGestureListener = new DragGestureListener()
{
public void dragGestureRecognized(DragGestureEvent e)
{
if (graphComponent.isDragEnabled() && first != null)
{
final TransferHandler th = graphComponent
.getTransferHandler();
if (th instanceof mxGraphTransferHandler)
{
final mxGraphTransferable t = (mxGraphTransferable) ((mxGraphTransferHandler) th)
.createTransferable(graphComponent);
if (t != null)
{
e.startDrag(null, mxSwingConstants.EMPTY_IMAGE,
new Point(), t, new DragSourceAdapter()
{
/**
*
*/
public void dragDropEnd(
DragSourceDropEvent dsde)
{
((mxGraphTransferHandler) th)
.exportDone(
graphComponent,
t,
TransferHandler.NONE);
first = null;
}
});
}
}
}
}
};
DragSource dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer(graphComponent
.getGraphControl(),
(isCloneEnabled()) ? DnDConstants.ACTION_COPY_OR_MOVE
: DnDConstants.ACTION_MOVE, dragGestureListener);
}