public void actionPerformed(ActionEvent ae) { try { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); if (object instanceof byte[]) { // FIXME: Does not seem to work properly BytesSelection bytesSelection = new BytesSelection((byte[]) object); clipboard.setContents(bytesSelection, bytesSelection); } else { // String StringSelection stringSelection = new StringSelection(object.toString()); clipboard.setContents(stringSelection, stringSelection); } } catch (Exception ex) { logger.warn("Could not copy " + object, ex); JOptionPane.showMessageDialog(ResultItemPanel.this, "Problem copying data : \n" + ex.getMessage(), "Exception!", JOptionPane.ERROR_MESSAGE); } } }