I am trying to do a simple copy and paste function for a jtable
I am sometimes able to copy and the paste function does not work at all. The class i have implements the ClipboardOwner. I am using the default table model as the model of the jtable.
Clipboard1 and Kit1 are both declared above as global values as part of the Clipboard and Toolkit class respectively. TableModel1 is the instance of my default table model and Table1 is the instance of my JTable
Here is my copying function
public void copy (String str1)
StringSelection data = new StringSelection(str1);
Kit1 = Toolkit.getDefaultToolkit();
Clipboard1 = Kit1.getSystemClipboard();
int d = Table1.getEditingColumn();
int d1 = Table1.getEditingRow();
String str3 = (String)TableModel1.getValueAt(d1, d);
This how i call the the pasting function
int d2 = Table1.getEditingColumn();
int d3 = Table1.getEditingRow();
String str3 = paste();
TableModel1.setValueAt(str3, d1, d);
Table1.setValueAt(str3, d1, d);
What i want to be able to do is that a person selects the particular cell and clicks a button the entire contents of that cell is put onto the clipboard and
the person clicks another button the entire contents of the clipboard are inserted into the currently selected cell.
Another question i have is that is there a way to retrieve only the selected content of a particular selected cell ?
At this point i am only require string flavor and nothing else and all the code compiles without any errors.