DZone Forums
Go Back   DZone Forums > Community > Languages & Frameworks > Java
Reload this Page drag-n-drop match
Notices
Reply
 
LinkBack Thread Tools Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Feb 2008
Question drag-n-drop match - 02-26-2008, 06:16 AM

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 ?


1a + 1b + 1c = 1 program
(a=keyboard, b=screen, c=logic)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse RCP drag and drop montassis Eclipse 0 01-07-2009 08:06 PM
Dynamic Drop-Down Command in 3.3+ Shambla Eclipse 0 09-22-2008 05:11 PM
My widgets gets palced in new row on drag & drop in Visual Editor pratibha Eclipse 1 03-12-2008 12:53 AM
Post icon labels don't match glennji Feedback 0 02-15-2008 10:01 AM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com