Last active
March 10, 2019 12:20
-
-
Save ezhov-da/920f90e2bf1921c6adcdcb5f23334d7f to your computer and use it in GitHub Desktop.
java перетягиваем файлы на кнопку
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[code:]java[:code] | |
/** | |
* класс, отвечающий за перетаскивание файлов на кнопку | |
*/ | |
private class BottomFileTrasferHandler extends TransferHandler | |
{ | |
@Override | |
public int getSourceActions(JComponent c) | |
{ | |
return TransferHandler.COPY_OR_MOVE; | |
} | |
@Override | |
public boolean canImport(TransferSupport support) | |
{ | |
return support.isDataFlavorSupported(DataFlavor.javaFileListFlavor); | |
} | |
@Override | |
public boolean importData(TransferSupport support) | |
{ | |
if (support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) | |
{ | |
try | |
{ | |
List<File> listFile; | |
listFile = (List<File>) support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor); | |
File[] files = (File[]) listFile.toArray(); | |
for (ActionFileAddListener actionFileAddListener : actionFileAddLcisteners) | |
{ | |
actionFileAddListener.addFile(files, list, JEFileChooser.this); | |
} | |
return true; | |
} catch (Exception ex) | |
{ | |
Logger.getLogger(JEFileChooser.class.getName()).log(Level.SEVERE, null, ex); | |
return false; | |
} | |
} | |
return false; | |
} | |
} | |
} | |
[/code] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment