Hi,
I'm implementing a drag-n-drop image program and have managed to do the
drag-n-drop operation, but my problem is that I can't find a way to match or
check whether the dragged item is dropped over the right target or not.
This is the source drag object:
Code:
printerLabel = new JLabel("Printer", icon1, JLabel.LEFT);
// tell it to enable the transfer
printerLabel.setTransferHandler(new PictureTransferHandler());
printerLabel.setBackground(new Color(255, 255, 10));
printerLabel.setOpaque(true);
printerLabel.setForeground(new Color(255, 255, 10));
This is a target drop object:
Code:
Icon icon4 = new ImageIcon("Printer");
printerLbl = new JLabel(icon4);
textFieldPanel.add(printerLbl);
printerLbl.setBackground(new Color(255,255,10));
printerLbl.setForeground(new Color(255,255,10));
printerLbl.setOpaque(true);
printerLbl.setTransferHandler(new PictureTransferHandler());
printerLbl.setBounds(30, 172, 110, 90);
And to test this, I simply have some button with action listener, to match
the drag source with the drop target.
Note: I had this working for text labels, for labels with image icons it seems
to be harder to do.
Any help or ideas ?