Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2005

Tip: Looking for answers? Try searching our database.

MouseEvent release on another component

Thread view: 
VisionSet - 20 Oct 2005 23:49 GMT
I'm trying to implement my own drag & drop (not between apps).  Having a
problem with mouseReleased event not firing events for the component it is
over.  I know about SwingUtils convertPoint but that relies on my knowing
the component to convert to. Is there any way I can guarantee I can find the
component based on its coordinates.  Does swing hold its own collection of
components in such away I can guarantee finding the one I want? (Even if in
different JFrames) If its traversable in this way I can check each one with
convertPoint and see if getBounds for that component contains that point.

Any other ideas?

TIA

--
Mike W
Andrew Thompson - 21 Oct 2005 00:39 GMT
> I'm trying to implement my own drag & drop ..

Why?

> Any other ideas?

Use the core API D'n'D classes that work?
VisionSet - 21 Oct 2005 13:44 GMT
> > I'm trying to implement my own drag & drop ..
>
[quoted text clipped - 3 lines]
>
> Use the core API D'n'D classes that work?

Okay I'll have another look at them, but last time I looked I was under the
impression this was for data transfer between apps.
Thanks.
--
Mike W
Andrew Thompson - 21 Oct 2005 14:41 GMT
>>>I'm trying to implement my own drag & drop ..  (inside one app.)

>>Why?

> ..last time I looked I was under the
> impression this was for data transfer between apps.

No.  I suspect they concentrate on 'inter-application' simply
because that covers all cases, from the simple to the complex.
I used D'n'D to implement a 'drag re-order' on a single list's
entries.

I found it hard to get a handle on D'n'D (only done a bit of it -
and that was some time ago), until I started dumping everything I
was dealing with to the debugger/console (especially with 'data flavors'
and such).
VisionSet - 21 Oct 2005 20:55 GMT
> >>>I'm trying to implement my own drag & drop ..  (inside one app.)
>
[quoted text clipped - 6 lines]
> was dealing with to the debugger/console (especially with 'data flavors'
> and such).

Messed about with it now, and it seems I can do anything I'd want to,
especially with the DropTarget classes.
Now I'm in two minds whether to have all my game pieces painted on or in
components.

I think a common approach is to draw the pieces on . But then I think what
about accessibility issues, sure be nice to be able use the focus framework
to tab along the pieces or whatever, so maybe components is the better
approach.

Apart from the accessibility, both seem equally ideal solutions.

--
Mike W
Andrew Thompson - 22 Oct 2005 05:28 GMT
D'n'D..

> Messed about with it now, and it seems I can do anything I'd want to,
> especially with the DropTarget classes.

Cool.

> Now I'm in two minds whether to have all my game pieces painted on or in
> components.

You've lost me.  I assume you are referring to the fact
that the draggable entities must be components, but what
about the reference to 'paint'?

FWIW - you can override paint in your draggable components.  (??)

..I go back to "You've lost me.".
VisionSet - 22 Oct 2005 11:12 GMT
> D'n'D..
>
[quoted text clipped - 9 lines]
> that the draggable entities must be components, but what
> about the reference to 'paint'?

I have a version where all my game pieces are just all painted on to their
component.
ie the pieces are NOT components.

> FWIW - you can override paint in your draggable components.  (??)
>
> ..I go back to "You've lost me.".

Ah, but the draggable does NOT have to be a component, you only need to pass
a reference of your source container to the TransferHandler...

protected Transferable createTransferable(JComponent sourceContainer)

Then you create a Transferable in anyway you see fit, in the version
described above I am getting some data from sourceContainer (an image and
model object) and wrapping it in a Transferable.

I'm now leaning towards changing it to components for accessibility reasons.
I will have a max of 100 game pieces, so they could all be JPanels, but only
7 are transferable at any one time, so I could paint the others on.

--
Mike W
Andrew Thompson - 22 Oct 2005 11:22 GMT
> I'm now leaning towards changing it to components for accessibility reasons.

Probably best.  You'll get those who might complain of the
'extra overhead', but I bet it is not noticeable in the way
the GUI actually behaves (unless you are talking about
*thousands* of transferables!).
VisionSet - 22 Oct 2005 11:32 GMT
> ...but I bet it is not noticeable in the way
> the GUI actually behaves (unless you are talking about
> *thousands* of transferables!).

No, I wrote some scrolling calendar thing once and it was only just
noticable with 6 months of day components on it.  And that was back at
JDK1.3. Obviously I don't do stuff like that anymore ;-)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.