Cut/Copy/Paste Don't Work for Tables?

  • Follow


I implemented cut/copy/paste for components in a JTree.  I usedTransferable and TransferHandler (works very nicely, BTW).  But, I'mhaving a problem.I can cut/copy/paste any item in the tree - it works as it should.When I open a view to the items in the tree (a property editor window)and attempt to cut/copy/paste, it works as it should (closes thewindow on cut and the paste works correctly) EXCEPT for one item inthe JTree.The item I can't copy and paste is exactly like the other items(inherits from the same base classes, etc.) except for the fact thatit has a class veriable of type DefaultTableModel.  When I remove thereference to that variable, cut/copy/paste of this component worksfine.Any idea why?  I can't get any errors/exceptions and my trace endssomewhere within the Java code (but I can't see the code to see what'shappening).  I thought it might have something to do withSerializable, but DefaultTableModel is Serializable.Thanks for any help.
0
Reply jason.cavett (211) 3/21/2007 8:25:54 PM

On Mar 21, 4:25 pm, "Jason Cavett" <jason.cav...@gmail.com> wrote:> I implemented cut/copy/paste for components in a JTree.  I used> Transferable and TransferHandler (works very nicely, BTW).  But, I'm> having a problem.>> I can cut/copy/paste any item in the tree - it works as it should.> When I open a view to the items in the tree (a property editor window)> and attempt to cut/copy/paste, it works as it should (closes the> window on cut and the paste works correctly) EXCEPT for one item in> the JTree.>> The item I can't copy and paste is exactly like the other items> (inherits from the same base classes, etc.) except for the fact that> it has a class veriable of type DefaultTableModel.  When I remove the> reference to that variable, cut/copy/paste of this component works> fine.>> Any idea why?  I can't get any errors/exceptions and my trace ends> somewhere within the Java code (but I can't see the code to see what's> happening).  I thought it might have something to do with> Serializable, but DefaultTableModel is Serializable.>> Thanks for any help.After a little more research, I have discovered that my problem isthis line..."productTable.setModel(production.getProducts());"getProducts() returns a ProductTableModel which extendsDefaultTableModel.  If I remove this line, I am then able to cut/copy/paste the component.Two weird things.1. This line occurs in the creation of my view for the productionobject.2. If the view is open, the problem occurs.  If the view is closed theproblem doesn't.  Either way, the object that I am copying/pasting(production) still has an object of type ProductTableModel.I am *really* confused.
0
Reply Jason 3/21/2007 8:41:21 PM


1 Replies
499 Views

(page loaded in 0.008 seconds)

Similiar Articles:













7/24/2012 4:08:05 AM


Reply: