本文整理汇总了Java中java.awt.dnd.DragSource.getDefaultDragSource方法的典型用法代码示例。如果您正苦于以下问题:Java DragSource.getDefaultDragSource方法的具体用法?Java DragSource.getDefaultDragSource怎么用?Java DragSource.getDefaultDragSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.dnd.DragSource
的用法示例。
在下文中一共展示了DragSource.getDefaultDragSource方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: run
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/** Performs DnD pre-heat.
*/
@Override
public void run() {
if (!GraphicsEnvironment.isHeadless()) {
DragSource.getDefaultDragSource();
}
}
示例4: 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);
}
示例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: DragSourceButton
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public DragSourceButton(String str) {
super(str);
DragSource ds = DragSource.getDefaultDragSource();
ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY,
this);
}
示例7: 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();
}
示例8: SwingDragGestureRecognizer
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
SwingDragGestureRecognizer() {
super(DragSource.getDefaultDragSource(), null, NONE, null);
}
示例9: FreeColDragGestureRecognizer
import java.awt.dnd.DragSource; //导入方法依赖的package包/类
FreeColDragGestureRecognizer(DragGestureListener dgl) {
super(DragSource.getDefaultDragSource(), null, NONE, dgl);
}