((JTextComponent)selectedComponent).cut();
((JTextComponent)selectedComponent).copy(); else if (selectedComponent instanceof JTree) { TreePath path = ((JTree)selectedComponent).getSelectionPath(); StringSelection data = new StringSelection(path.getLastPathComponent().toString()); Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); cb.setContents(data, data); }
    private void copyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyActionPerformed        if (selectedComponent == null)            return;                if (selectedComponent instanceof JTextComponent)            ((JTextComponent)selectedComponent).cut();        else if (selectedComponent instanceof JList) {            StringSelection path = new StringSelection(buildSelectPath((JList)selectedComponent));            Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();            cb.setContents(path, path);        }            }//GEN-LAST:event_copyActionPerformed