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 / First Aid / February 2006

Tip: Looking for answers? Try searching our database.

Negative MouseEvent

Thread view: 
Grethe - 16 Feb 2006 12:54 GMT
Hi

I'm having a bit of trouble understanding MouseEvent. For some reason I'm
able to make it return a negative point on mousePressed when printing out
getPoint. How is this possible? I dont see how it is possible to trigger a
MouseEvent on a component that has a MouseListener without the clicking
point being inside the component. Im using java 1.1.8(Don't ask why). Is
this a bug in Java 1.1?

java.awt.Point[x=-17,y=38]

Mike
Rhino - 16 Feb 2006 14:15 GMT
> Hi
>
[quoted text clipped - 6 lines]
>
> java.awt.Point[x=-17,y=38]

The coordinate system is based on the default origin, (0,0), being in the
upper left corner. That results in both the X and Y coordinates of any point
being positive since every point south or east of the origin has a higher X
or Y coordinate than zero.

But there is a method, translate(), that can change the origin to some other
point. Is it possible that your code does a translate()? That could explain
your results.

--
Rhino
Mike - 16 Feb 2006 14:49 GMT
> But there is a method, translate(), that can change the origin to some
> other point. Is it possible that your code does a translate()? That could
> explain your results.

My code does not use translate at any point. If translate is used it is done
within AWT. But the thing is that im not doing anything to change the
result. It's the point directly from the event thats negative. I strongly
suspect its a bug since java 1.1 is very buggy. Its no problem fixing it. I
just make sure to check for negative values. But since in my mind it
shouldnt be possible to get a negative value from mousePressed i think its a
bug.

Mike
Monique Y. Mudama - 16 Feb 2006 17:43 GMT
>> But there is a method, translate(), that can change the origin to
>> some other point. Is it possible that your code does a translate()?
[quoted text clipped - 7 lines]
> values. But since in my mind it shouldnt be possible to get a
> negative value from mousePressed i think its a bug.

Having to use 1.1 is like having to code with your hands tied behind
your back.

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Mike - 17 Feb 2006 11:29 GMT
> Having to use 1.1 is like having to code with your hands tied behind
> your back.

agreed. however i have no choice since its my job:\

Mike
Roedy Green - 17 Feb 2006 04:59 GMT
On Thu, 16 Feb 2006 09:15:48 -0500, "Rhino"
<no.offline.contact.please@nospam.com> wrote, quoted or indirectly
quoted someone who said :

>The coordinate system is based on the default origin, (0,0), being in the
>upper left corner. That results in both the X and Y coordinates of any point
>being positive since every point south or east of the origin has a higher X
>or Y coordinate than zero.
see http://mindprod.com/jgloss/coordinates.html
for a pictorial explanation
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Mike - 17 Feb 2006 11:27 GMT
> see http://mindprod.com/jgloss/coordinates.html
> for a pictorial explanation

The problem is not wether i understand how coordinates work i java. The
question is: is it possible to get a negative point when mousePressed is
called or is this a bug in java 1.1?
Roedy Green - 18 Feb 2006 00:54 GMT
>The problem is not wether i understand how coordinates work i java. The
>question is: is it possible to get a negative point when mousePressed is
>called or is this a bug in java 1.1?

A could see a negative point occurring like this.  A mouse click comes
in. Through magical processes it arrives at the Container. The
container looks at the bounds of all its contents and picks the one
containing the point. If it can't find one it has to deal with it
itself.  It then selects triggers the event handler of the content
component with the x,y adjusted to be relative to the component.

What could happen to screw this up?

Mainly a second thread meddling, say moving or resizing components
while the container was in the process of dispatching the event.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Mike - 18 Feb 2006 10:47 GMT
> A could see a negative point occurring like this.  A mouse click comes
> in. Through magical processes it arrives at the Container. The
[quoted text clipped - 7 lines]
> Mainly a second thread meddling, say moving or resizing components
> while the container was in the process of dispatching the event.

Interesting point. Actually it occurs while moving(animating) an object. So
basically its a synchronization issue?
Im still a bit puzzled about how it can occur. I would like java to be able
to handle this synchronization issue. But am i wrong in assuming that?

Mike.


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.