⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e640. making a component draggable.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
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.
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -