Transferable (JComponent c) { final Object selection = tree.getLastSelectedPathComponent(); if (!(selection instanceof DefaultMutableTreeNode node)) { return null; } if (!(node.getUserObject() instanceof Configuration)) { return null; } return new TextTransferable(ConfigurationUtil.toXml((Configuration)node.getUserObject())); }