protected Transferable createTransferable(JComponent c){
  if (c instanceof JList) {
    JList list=(JList)c;
    Object[] values=list.getSelectedValues();
    if (values == null || values.length == 0) {
      return null;
    }
    StringBuffer plainBuf=new StringBuffer();
    StringBuffer htmlBuf=new StringBuffer();
    htmlBuf.append("<html>\n<body>\n<ul>\n");
    for (int i=0; i < values.length; i++) {
      Object obj=values[i];
      String val=((obj == null) ? "" : obj.toString());
      plainBuf.append(val + "\n");
      htmlBuf.append("  <li>" + val + "\n");
    }
    plainBuf.deleteCharAt(plainBuf.length() - 1);
    htmlBuf.append("</ul>\n</body>\n</html>");
    return new BasicTransferable(plainBuf.toString(),htmlBuf.toString());
  }
  return null;
}

protected Transferable createTransferable ( JComponent c ) { if ( c instanceof JList ) { JList list = ( JList ) c ; Object [ ] values = list . getSelectedValues ( ) ; if ( values == null || values . length == 0 ) { return null ; } StringBuffer plainBuf = new StringBuffer ( ) ; StringBuffer htmlBuf = new StringBuffer ( ) ; htmlBuf . append ( "<html>\n<body>\n<ul>\n" ) ; for ( int i = 0 ; i < values . length ; i ++ ) { Object obj = values [ i ] ; String val = ( ( obj == null ) ? "" : obj . toString ( ) ) ; plainBuf . append ( val + "\n" ) ; htmlBuf . append ( "  <li>" + val + "\n" ) ; } plainBuf . deleteCharAt ( plainBuf . length ( ) - 1 ) ; htmlBuf . append ( "</ul>\n</body>\n</html>" ) ; return new BasicTransferable ( plainBuf . toString ( ) , htmlBuf . toString ( ) ) ; } return null ; }
create a transferable to use as the source for a data transfer .
