473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

mouse coordinates of drop (as in drag and drop)

cte
I have a swing program involving drag and drop - implemented with
javax.swing.TransferHandler etc.

My problem is that I want to determine the mouse coordinates of a drop
onto one of my components and TransferHandler does not seem to have
any means of doing this.

The swing DnD API seems to smoother any mouse listeners that I put up,
so I don't think that approach will work.

Is there some kind of method like getMouseCoordinates () for either a
JComponent or enclosing JFrame etc?

Regards
Chris
Jul 17 '05 #1
1 3251
cte
ct*****@yahoo.com.au (cte) wrote in message news:<c1**************************@posting.google. com>...
I have a swing program involving drag and drop - implemented with
javax.swing.TransferHandler etc.

My problem is that I want to determine the mouse coordinates of a drop
onto one of my components and TransferHandler does not seem to have
any means of doing this.


I don't know if it's bad form to reply to my own post but I've worked
out a semi-solution that does enough. There's a method in
java.awt.Component (which is an ancestor of JComponent): public
DropTarget getDropTarget (). I was able to call this method which
retrieves the Swing implementation (an inner class of
TransferHandler), and add a java.awt.dnd.DropTargetListener to it.

Now for the dodgy bit ;D. The documentation for DropTarget indicates
that only one DropTargetListener may be attached to a DropTarget and
an Exception is thrown if you try to add more than one. However the
inner class of TransferHandler that is a DropTarget does *not* throw
an Exception. Lucky for me, but I'm also uncomfortable relying on a
private implementation detail like this...

Cheers
Chris
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robin Senior | last post by:
Hi, I'm trying to drag and drop onto a Panel on my form. The panel is inside a groupBox, which of course is inside my form. When dropping the item onto my Panel, I want it to appear at that...
1
by: Curtis Justus | last post by:
Hi, My goal is to have a series of thumbnail images on a control/panel and to drag/drop those items onto another control (i.e. a treeview). I am able to drag one item and need to somehow select...
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
14
by: Nathan | last post by:
I'm working for the first time with the DoDragDrop method. I've got almost everything worked out, but I need some help with the last bit. There are two listboxes on my form, lstGroups and...
1
by: Dawoodmm | last post by:
Hi i have a sight problem with detecting the mouse up in a drag-drop outside a form what i have on my hands is an mdi form with 2 child forms: form1 and form2, both containing a label each. i also...
1
by: timnels | last post by:
I have created a muti-select treeview control. Problem is I am now trying to implement drag/drop in the application that uses it. It seems the mouse down and mouse move events fire before the...
4
by: atn2002 | last post by:
How can I track the mouse coordinates outside the active window? No one can tell me its not possible because Google Spreadsheets and EditGrid both do it. When you drag down to select cells these...
0
by: arvinds | last post by:
I have an application in which I have 2 forms. 1.Review Form 2. FilmForm. Review Form is used for Loading some images and we can transfer the Images from Review From to FilmForm by Drag-Drop...
2
by: bob | last post by:
Hi all, I have a treeview that has drag drop. Works well enough but... If you drag out of bounds of the treeview the nodrop icon comes on. Fair enough. But when I move back inside the treeview...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.