6
6e
Please notice that my question is about a specific error, not drag and
drop. I followed the information on
http://www.javaworld.com/javaworld/javatips/jw-javatip97.html for drag
and drop.
For anyone not familiar with this it basically describes how to
properly implement transferable and serializable so that drag and drop
is possible on jtree's.
However my problem seems to occur on the second time that I drag and
drop an object. I use a unique node that is attached to a unique
jtable object ( I call this object TreeNodeTableLink). I do not
receive a program crashing error, but rather one that I have to catch,
and one that seems to cripple my jtree linked to my jtable.
Both my jtable and my node objects implement serializabe (as I
discovered was neccessary on http://www.devx.com/tips/Tip/13020 ).
The problem occurs in the public void drop(DropTargetDropEvent e)
function on this line:
//cast into appropriate data type
TreeNodeTableLink childInfo = (TreeNodeTableLink)
tr.getTransferData(tntlFlavor);
I catch the IOException and print a stack trace which pointed me to
this line. I'm pretty confused as to what the problem is, does anyone
have any ideas about how I may be able to correct this problem? Or has
anyone experienced this "error" before and successfully solved it? I
think Im losing it...
Thanks for your help!
----------code---------------
// DropTargetListener interface method - What we do when drag is
released
public void drop(DropTargetDropEvent e) {
System.out.println("TreeLinking : drop");
try {
Transferable tr = e.getTransferable();
//flavor not supported, reject drop
if (!tr.isDataFlavorSupported(TreeNodeTableLink.tntlFlavor)){
e.rejectDrop();
}
else{
System.out.println("Dataflavor Supported");
}
//cast into appropriate data type
TreeNodeTableLink childInfo = (TreeNodeTableLink)
tr.getTransferData(tntlFlavor);
//ERROR
drop. I followed the information on
http://www.javaworld.com/javaworld/javatips/jw-javatip97.html for drag
and drop.
For anyone not familiar with this it basically describes how to
properly implement transferable and serializable so that drag and drop
is possible on jtree's.
However my problem seems to occur on the second time that I drag and
drop an object. I use a unique node that is attached to a unique
jtable object ( I call this object TreeNodeTableLink). I do not
receive a program crashing error, but rather one that I have to catch,
and one that seems to cripple my jtree linked to my jtable.
Both my jtable and my node objects implement serializabe (as I
discovered was neccessary on http://www.devx.com/tips/Tip/13020 ).
The problem occurs in the public void drop(DropTargetDropEvent e)
function on this line:
//cast into appropriate data type
TreeNodeTableLink childInfo = (TreeNodeTableLink)
tr.getTransferData(tntlFlavor);
I catch the IOException and print a stack trace which pointed me to
this line. I'm pretty confused as to what the problem is, does anyone
have any ideas about how I may be able to correct this problem? Or has
anyone experienced this "error" before and successfully solved it? I
think Im losing it...
Thanks for your help!
----------code---------------
// DropTargetListener interface method - What we do when drag is
released
public void drop(DropTargetDropEvent e) {
System.out.println("TreeLinking : drop");
try {
Transferable tr = e.getTransferable();
//flavor not supported, reject drop
if (!tr.isDataFlavorSupported(TreeNodeTableLink.tntlFlavor)){
e.rejectDrop();
}
else{
System.out.println("Dataflavor Supported");
}
//cast into appropriate data type
TreeNodeTableLink childInfo = (TreeNodeTableLink)
tr.getTransferData(tntlFlavor);
//ERROR