472,809 Members | 3,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,809 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 3207
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?

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.