-1

我有这个标签:

//---- label5 ----
label5.setText("Drag and drop your texture\npack in the box *.zip files");
label5.setIcon(new ImageIcon(
    "E:\\Chituri\\MBMLauncherJava\\src\\resursele\\dasdasdasd.png"));

但我想做这样的事情:

//---- label5 ----
label5.setText("Drag and drop your texture\npack in the box *.zip files");
label5.setIcon(new ImageIcon(
    "E:\\Chituri\\MBMLauncherJava\\src\\resursele\\dasdasdasd.png"));
// drag files in the label > 
// automatically move files in particular folder (E:\\Chituri)

我怎么能做到这一点?

我试试这个...

label5.setTransferHandler(transfer);
label5.addMouseListener(new MouseAdapter(){
                public void mousePressed(MouseEvent e){
                    JLabel texturidrag = (JLabel)e.getSource();
                    TransferHandler handle = texturidrag.getTransferHandler();
                    handle.exportAsDrag(texturidrag, e, TransferHandler.COPY);
                }
            });
4

1 回答 1

1

尝试阅读这篇文章,特别是回答和实现processFiles过滤输入文件和只处理图像的方法,如果你发现图像只是ImageIcon你想要的。

于 2012-06-10T11:28:42.077 回答