java.lang.Object
javax.swing.TransferHandler
org.bzdev.swing.DebugTransferHandler
- All Implemented Interfaces:
Serializable
TransferHandler that lists data flavors and objects being transferred.
It outputs information about the transfer to an Appendable (a common
interface implemented by a number of classes, including PrintStream,
PrintWriter, CharBuffer, Writer, StringBuilder, and StringBuffer. This
class should be used only for debugging and not as part of a released
application. It is intended for cases in which one would like to trace
the operation of a TransferHandler when the source code for the
TransferHandler is not available or cannot be modified for some reason.
For example, given a JComponent
c
, one could call
c.setTransferHandler(new DebugTransferHandler(c.getTransferHandler(),
System.out));
to trace a drag and drop operation, showing the data flavors that are
available and their values. In some cases, the data flavor used is
system dependent and may change from release to release, so being able
to add tracing of drag and drop operations quickly is advantageous,
and some of the data flavors used in practice are not mentioned in the
Java documentation (for example, some if not all versions of the Nautilus
file manager on Linux/Gnome systems will use lists of URLs when dragging
and dropping files).
The class is a wrapper for an existing TransferHandler, with a default behavior if the wrapped TransferHandler is null.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.TransferHandler
TransferHandler.DropLocation, TransferHandler.TransferSupport
-
Field Summary
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.DebugTransferHandler
(TransferHandler handler, Appendable out) Constructor wrapping an existing TransferHandler. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canImport
(TransferHandler.TransferSupport support) protected Transferable
void
exportAsDrag
(JComponent source, InputEvent e, int action) protected void
exportDone
(JComponent source, Transferable data, int action) void
exportToClipboard
(JComponent comp, Clipboard clip, int action) int
boolean
importData
(JComponent comp, Transferable t) boolean
Methods inherited from class javax.swing.TransferHandler
canImport, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, setDragImage, setDragImageOffset
-
Constructor Details
-
DebugTransferHandler
Constructor.- Parameters:
out
- the output character stream or object
-
DebugTransferHandler
Constructor wrapping an existing TransferHandler.- Parameters:
handler
- the transfer handler to wrapout
- the output character stream, writer, or object
-
-
Method Details
-
createTransferable
- Overrides:
createTransferable
in classTransferHandler
-
exportAsDrag
- Overrides:
exportAsDrag
in classTransferHandler
-
exportToClipboard
- Overrides:
exportToClipboard
in classTransferHandler
-
getSourceActions
- Overrides:
getSourceActions
in classTransferHandler
-
getVisualRepresentation
- Overrides:
getVisualRepresentation
in classTransferHandler
-
importData
- Overrides:
importData
in classTransferHandler
-
importData
- Overrides:
importData
in classTransferHandler
-
canImport
- Overrides:
canImport
in classTransferHandler
-
exportDone
- Overrides:
exportDone
in classTransferHandler
-