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

📄 e742. adding drag-and-drop support to a jlabel component.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
This example demonstrates how to modify a label component so that its text can be dragged and dropped to another component. 
    // Create a label
    JLabel label = new JLabel("Label Text");
    
    // Specify that the label's text property be transferable; the value of
    // this property will be used in any drag-and-drop involving this label
    final String propertyName = "text";
    label.setTransferHandler(new TransferHandler(propertyName));
    
    // Listen for mouse clicks
    label.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent evt) {
            JComponent comp = (JComponent)evt.getSource();
            TransferHandler th = comp.getTransferHandler();
    
            // Start the drag operation
            th.exportAsDrag(comp, evt, TransferHandler.COPY);
        }
    });

⌨️ 快捷键说明

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