tree.getLastSelectedPathComponent();
if (node == null) {
return;
}
// is it better to use SwingUtilities2.canAccessSystemClipboard() here?
Clipboard clipboard;
try {
clipboard = tree.getToolkit().getSystemClipboard();
} catch (SecurityException e) {
return;
} catch (HeadlessException e) {
return;
}
if (clipboard == null) {
return;
}
StringBuilder text = new StringBuilder();
treeLogTraverse(text, node, 0);
StringSelection selection = new StringSelection(text.toString());
clipboard.setContents(selection, selection);
}