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

J

Jason Cavett

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.
 
J

Jason Cavett

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 is
this line...

"productTable.setModel(production.getProducts());"

getProducts() returns a ProductTableModel which extends
DefaultTableModel. 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 production
object.
2. If the view is open, the problem occurs. If the view is closed the
problem doesn't. Either way, the object that I am copying/pasting
(production) still has an object of type ProductTableModel.

I am *really* confused.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top