当前位置: 首页>>代码示例>>Java>>正文


Java DragSource.isDragImageSupported方法代码示例

本文整理汇总了Java中java.awt.dnd.DragSource.isDragImageSupported方法的典型用法代码示例。如果您正苦于以下问题:Java DragSource.isDragImageSupported方法的具体用法?Java DragSource.isDragImageSupported怎么用?Java DragSource.isDragImageSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.dnd.DragSource的用法示例。


在下文中一共展示了DragSource.isDragImageSupported方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public void start() {
    Frame f = new Frame("Use keyboard for DnD change");
    Panel mainPanel;
    Component dragSource, dropTarget;

    f.setBounds(0, 400, 200, 200);
    f.setLayout(new BorderLayout());

    mainPanel = new Panel();
    mainPanel.setLayout(new BorderLayout());

    mainPanel.setBackground(Color.blue);

    dropTarget = new DnDTarget(Color.red, Color.yellow);
    dragSource = new DnDSource("Drag ME! (" + (DragSource.isDragImageSupported()?"with ":"without") + " image)" );

    mainPanel.add(dragSource, "North");
    mainPanel.add(dropTarget, "Center");
    f.add(mainPanel, BorderLayout.CENTER);

    f.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:ImageDecoratedDnD.java

示例2: start

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public void start() {
    Frame f = new Frame("Use keyboard for DnD change");
    Panel mainPanel;
    Component dragSource, dropTarget;

    f.setBounds(0, 400, 200, 200);
    f.setLayout(new BorderLayout());

    mainPanel = new Panel();
    mainPanel.setLayout(new BorderLayout());

    mainPanel.setBackground(Color.blue);

    dropTarget = new DnDTarget(Color.red, Color.yellow);
    dragSource = new DnDSource("Drag ME! (" + (DragSource.isDragImageSupported()?"with ":"without") + " image)" );

    mainPanel.add(dragSource, "North");
    mainPanel.add(dropTarget, "Center");
    f.add(mainPanel, BorderLayout.CENTER);

    f.setVisible(true);
    try {
        Point sourcePoint = dragSource.getLocationOnScreen();
        Dimension d = dragSource.getSize();
        sourcePoint.translate(d.width / 2, d.height / 2);

        Robot robot = new Robot();
        robot.mouseMove(sourcePoint.x, sourcePoint.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        Thread.sleep(2000);
        for(int i = 0; i <100; ++i) {
            robot.mouseMove(
                sourcePoint.x + d.width / 2 + 10,
                sourcePoint.y + d.height);
            Thread.sleep(100);

            robot.mouseMove(sourcePoint.x, sourcePoint.y);
            Thread.sleep(100);

            robot.mouseMove(
                sourcePoint.x,
                sourcePoint.y + d.height);
            Thread.sleep(100);
        }
        sourcePoint.y += d.height;
        robot.mouseMove(sourcePoint.x, sourcePoint.y);
        Thread.sleep(100);

        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        Thread.sleep(4000);
    } catch( Exception e){
    e.printStackTrace();
        throw new RuntimeException("test failed: drop was not successful with exception " + e);
    }

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:57,代码来源:ImageDecoratedDnDInOut.java


注:本文中的java.awt.dnd.DragSource.isDragImageSupported方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。