Jtable content to system clipboard

M

Marc Van Laer

Hi all,

I'm trying to copy a JTable to my system clipboard.
So far i've been unsuccesfull.
Has anyone done this before?
Is it even possible?

Thanks in advance,

Marc Van Laer
 
R

Roland

Hi all,

I'm trying to copy a JTable to my system clipboard.
So far i've been unsuccesfull.
Has anyone done this before?
Is it even possible?

Thanks in advance,

Marc Van Laer
To copy selected table rows, you can use Java's built-in support:

TransferHandler th = myTable.getTransferHandler();
if (th != null) {
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
th.exportToClipboard(myTable, cb, TransferHandler.COPY);
}

If you want to copy the entire table contents, you probably have to
write it yourself. Have a look at the source code of the nested class
TableTransferHandler in javax.swing.plaf.basic.BasicTableUI.
--
Regards,

Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
 

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,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top