Class FileTransferHandler

    • Constructor Detail

      • FileTransferHandler

        public FileTransferHandler()
    • Method Detail

      • addSingleFileDragAndDropSupport

        public static void addSingleFileDragAndDropSupport​(JTextComponent textComponent)
        Makes the text component accept files during drag and drop operations and insert the absolute path of the dropped file (the first file in a list if more than one file is dropped)
        Parameters:
        textComponent - the text component
      • isFileDataFlavor

        public static boolean isFileDataFlavor​(TransferHandler.TransferSupport transferSupport)
        Parameters:
        transferSupport - a drag'n drop transfer support instance
        Returns:
        true if the given transfer support instance represents a file or a list of files
      • transferFiles

        public static List<File> transferFiles​(TransferHandler.TransferSupport transferSupport)
        Returns the files described by the given transfer support object. An empty list is returned if no files are found.
        Parameters:
        transferSupport - the drag'n drop transfer support
        Returns:
        the files described by the given transfer support object
        Throws:
        RuntimeException - in case of an exception
      • importFiles

        protected abstract boolean importFiles​(Component component,
                                               List<File> files)
        Called after a successful import
        Parameters:
        component - the component
        files - the imported files, non-null and containing at least one item
        Returns:
        true if the files were inserted into the component, false otherwise