Hi,
Can I drag a JLabel
and insert into it a custom object or should I use another component? But I have to use TransferHandler
with exportAsDrag
.
My code:
final JLabel label1 = new JLabel("Drag here");
Collection<Person> person= new ArrayList<Person>();
//Register transferhandler objects on them label1 transfer itss
//foreground coloer label2 transfer its backgroundcolor
//need here a Transferable to put the object
label1.setTransferHandler(new TransferHandler(....));
label1.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
// TODO Auto-generated method stub
TransferHandler handler = label1.getTransferHandler();
handler.exportAsDrag(label1, e, TransferHandler.COPY);
}
});