The Drop Target (a label with icon):
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);
The source (a label to be dragged):
Code:
peripheralLabel = new JLabel("Peripherals", icon3, JLabel.CENTER);
// tell it to enable the transfer of the icon
peripheralLabel.setTransferHandler(new PictureTransferHandler());
peripheralLabel.setBackground(new Color(255, 255, 10));
peripheralLabel.setForeground(new Color(255, 255, 10));
peripheralLabel.setOpaque(true);
peripheralLabel.setBounds(298, 19, 127, 98);
I then have a TestButton, which will try and check if there is a match
between the source label and the destination label, based on a name or
text description ?
Hope this makes things a bit clearer...