permaculture playing cards
The moose likes Swing / AWT / SWT and the fly likes Dnd not serializable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Dnd not serializable" Watch "Dnd not serializable" New topic

Dnd not serializable

Brian Snyder2002

Joined: Jan 24, 2002
Posts: 11
I have a Transferable and Serializable object User. When I try to drop it on a registered Component I get the error:
Why? I do a System.out.println(user.getUsername()); on the drag and it is a user. So I know it is of typwe user. I have also implemented the correct DataFlavor. Pleasee help!!!
public class User implements Transferable, Serializable, IXMLSerializeable, TreeNode{
// --------- Transferable --------------
public boolean isDataFlavorSupported(DataFlavor df) {
return df.equals(INFO_FLAVOR);
/** implements Transferable interface */
public Object getTransferData(DataFlavor df)
throws UnsupportedFlavorException {
if (df.equals(INFO_FLAVOR)) {
return this;
else throw new UnsupportedFlavorException(df);
/** implements Transferable interface */
public DataFlavor[] getTransferDataFlavors() {
return flavors;

Java Developer<br />SCJ2P
Joe Gilvary
Ranch Hand

Joined: May 11, 2001
Posts: 152
Look carefully at the error. It is a CharArrayWriter
that is not serializable. IO streams are not
serializable, which makes sense when you think
about it.
Declare the CharArrayWriter transient in the
User class. You will need to code to support
the dropped User needing a new Writer if you
try to write().
Brian Snyder2002

Joined: Jan 24, 2002
Posts: 11
Thanks Joe!
I actually fix the problem by creating a Wrapper class to hold my User class and future classes. On the drop, I get the singleton reference and extract the object that way. I don;t even have to use Transferable!!! Nice!!!
Many thanks!
I agree. Here's the link:
subject: Dnd not serializable
It's not a secret anymore!