protected Transferable createTransferable(JComponent c){
  if (c instanceof JTree) {
    tree=(JTree)c;
    TreePath[] paths=tree.getSelectionPaths();
    if (paths == null || paths.length == 0) {
      return null;
    }
    StringBuffer plainBuf=new StringBuffer();
    StringBuffer htmlBuf=new StringBuffer();
    htmlBuf.append("<html>\n<body>\n<ul>\n");
    TreeModel model=tree.getModel();
    TreePath lastPath=null;
    TreePath[] displayPaths=getDisplayOrderPaths(paths);
    for (    TreePath path : displayPaths) {
      Object node=path.getLastPathComponent();
      boolean leaf=model.isLeaf(node);
      String label=getDisplayString(path,true,leaf);
      plainBuf.append(label + "\n");
      htmlBuf.append("  <li>" + label + "\n");
    }
    plainBuf.deleteCharAt(plainBuf.length() - 1);
    htmlBuf.append("</ul>\n</body>\n</html>");
    tree=null;
    return new BasicTransferable(plainBuf.toString(),htmlBuf.toString());
  }
  return null;
}

protected Transferable createTransferable ( JComponent c ) { if ( c instanceof JTree ) { tree = ( JTree ) c ; TreePath [ ] paths = tree . getSelectionPaths ( ) ; if ( paths == null || paths . length == 0 ) { return null ; } StringBuffer plainBuf = new StringBuffer ( ) ; StringBuffer htmlBuf = new StringBuffer ( ) ; htmlBuf . append ( "<html>\n<body>\n<ul>\n" ) ; TreeModel model = tree . getModel ( ) ; TreePath lastPath = null ; TreePath [ ] displayPaths = getDisplayOrderPaths ( paths ) ; for ( TreePath path : displayPaths ) { Object node = path . getLastPathComponent ( ) ; boolean leaf = model . isLeaf ( node ) ; String label = getDisplayString ( path , true , leaf ) ; plainBuf . append ( label + "\n" ) ; htmlBuf . append ( "  <li>" + label + "\n" ) ; } plainBuf . deleteCharAt ( plainBuf . length ( ) - 1 ) ; htmlBuf . append ( "</ul>\n</body>\n</html>" ) ; tree = null ; return new BasicTransferable ( plainBuf . toString ( ) , htmlBuf . toString ( ) ) ; } return null ; }
create a transferable to use as the source for a data transfer .
