本文整理汇总了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);
}
示例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);
}
}