Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Implementing Cut/Copy/Paste

Thread view: 
Jason Cavett - 08 Mar 2007 14:20 GMT
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
Andrew Thompson - 09 Mar 2007 02:28 GMT
> 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...

I do not have much time (nor a detailed experience
of D'n'D) but can comment..
..
> What does DataFlavor have to do with anything?

If you copy text from a table in HTML, it might
be availabe as either an HTML formatted table
(as HTML format) or raw text (with each table
row in a single line).  Those are two different
DataFlavors.

(snip)
> Any clarification or simple examples that can be provided would be
> much appreciated.  I'll keep reading the tutorial and trying things
> out.

One example that touches o part of what you are
doing is one I did to demonstrate the JNLP API
copy/paste functionality - it is designed to
show DataFlavors.
<http://www.physci.org/jws/#cbs>

HTH

Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.