-1
private JList attributesList;
public AttributeGroupComponent(ArrayList<?> items) {
attributesList = new JList(items.toArray());
initGui();
}
private void initGui(){
attributesList.setDragEnabled(true);
}
然後在其他組件我嘗試JList的阻力CustomObject但下降字符串
public void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(DnDConstants.ACTION_COPY);
Transferable tr = dtde.getTransferable();
MyCustomClass ac = null;
try {
ac = (MyCustomClass)tr.getTransferData(flavor);
// And Here I get toString of my custom class!
// But I expected MyCustomClass Object!
} catch (UnsupportedFlavorException e) {
;// TODO
} catch (IOException e) {
;// TODO
}
dtde.dropComplete(true);
System.out.println("drop complete");
}
你的具體問題是什麼? – jzd 2011-05-23 12:13:21
另外,你使用什麼味道? SSCCE會很好。 – jzd 2011-05-23 12:14:22