Class SingleFileDragInTransferHandler
java.lang.Object
javax.swing.TransferHandler
org.jjazz.uiutilities.api.SingleFileDragInTransferHandler
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
MixConsoleTopComponent.TcTransferHandler
A drag'n drop support to accept a single file via drag & drop.
This class takes into account OS specific "glitches" of the Swing drag & drop support : behaviour is different on MacOS, getSourceActions(), createTransferable(), exportDone() can be called several times during a drag operation, but only once for Win/Linux. Also on MacOS the support parameter is not always fully initialized on canImport(), it is fully initialized only when importData() is called.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.TransferHandler
TransferHandler.DropLocation, TransferHandler.TransferSupport -
Field Summary
FieldsFields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanImport(TransferHandler.TransferSupport support) static FilegetAcceptedFile(TransferHandler.TransferSupport support, Collection<String> extensions) Check if TransferSupport contains a single file which matches one of the specified extensions.booleanMethods inherited from class javax.swing.TransferHandler
canImport, exportAsDrag, exportToClipboard, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, getSourceActions, getVisualRepresentation, importData, setDragImage, setDragImageOffset
-
Field Details
-
DRAG_MIDI_FILE_ICON
-
-
Constructor Details
-
SingleFileDragInTransferHandler
public SingleFileDragInTransferHandler()
-
-
Method Details
-
canImport
- Overrides:
canImportin classTransferHandler
-
importData
- Overrides:
importDatain classTransferHandler
-
getAcceptedFile
public static File getAcceptedFile(TransferHandler.TransferSupport support, Collection<String> extensions) Check if TransferSupport contains a single file which matches one of the specified extensions.NOTE: see comment, can return an empty File to avoid a Windows-specific problem.
- Parameters:
support-extensions- List of file extensions such as "sng" or "mid"- Returns:
- Null if no accepted file found
-