J
Jason Cavett
I am reading this tutorial on Data Transfer in Java:
http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.html
So far, this is the way I understand it...
1. Data is bundled into a Transferable object. This is done via a
TransferHandler.
2. The Transferable object is stored on the clipboard.
3. When the clipboard is accessed, the TransferHandler extracts the
Transferable object and does whatever needs to be done with this
object.
Also, many/most of the components already have cut/copy/paste
available and ready to be used.
I'm confused about quite a few things, though...
1. I need a generic way to handle all cut/copy/paste methods from
various different objects - JTextField, JTree, JLabels on a JPanel.
The JTextField (sorta) works right now. I'm guessing that's the cut/
copy/paste that's already been implemented. But my JTree holds its
own type of data and my JLabels that I want to cut/copy/paste from the
JPanel do not respond at all. I'm not sure where to begin.
2. Is the TraferHandler a separate class? Is the Transferable object
a separate class or is Transferable implemented by my data object?
What does DataFlavor have to do with anything?
The discussion of drag/drop in the tutorial is confusing me somewhat
and I've searched for some simple examples (all I care about is cut/
copy/paste - I do not care about drag and drop) but I haven't come up
with a whole lot.
Any clarification or simple examples that can be provided would be
much appreciated. I'll keep reading the tutorial and trying things
out.
Thanks
http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.html
So far, this is the way I understand it...
1. Data is bundled into a Transferable object. This is done via a
TransferHandler.
2. The Transferable object is stored on the clipboard.
3. When the clipboard is accessed, the TransferHandler extracts the
Transferable object and does whatever needs to be done with this
object.
Also, many/most of the components already have cut/copy/paste
available and ready to be used.
I'm confused about quite a few things, though...
1. I need a generic way to handle all cut/copy/paste methods from
various different objects - JTextField, JTree, JLabels on a JPanel.
The JTextField (sorta) works right now. I'm guessing that's the cut/
copy/paste that's already been implemented. But my JTree holds its
own type of data and my JLabels that I want to cut/copy/paste from the
JPanel do not respond at all. I'm not sure where to begin.
2. Is the TraferHandler a separate class? Is the Transferable object
a separate class or is Transferable implemented by my data object?
What does DataFlavor have to do with anything?
The discussion of drag/drop in the tutorial is confusing me somewhat
and I've searched for some simple examples (all I care about is cut/
copy/paste - I do not care about drag and drop) but I haven't come up
with a whole lot.
Any clarification or simple examples that can be provided would be
much appreciated. I'll keep reading the tutorial and trying things
out.
Thanks