This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: small fix for MouseEvent


Here is a patch to correct a small bug I discovered while I was
working on my pet project, (<URL:http://www.ii.uib.no/~rolfwr/jcnix/>).

All coordinates in the java.awt.event.MouseEvent uses the coordinate
space of the component, i.e. top-left of component is the origin. The
"get"-methods should not translate the coordinates, but rather return
the same values that were given to the constructor.


2000-06-27  Rolf W. Rasmussen  <rolfwr@ii.uib.no>

        * java/awt/event/MouseEvent.java: Fixed coordinate space confusion.


Index: libgcj/libjava/java/awt/event/MouseEvent.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/awt/event/MouseEvent.java,v
retrieving revision 1.1
diff -c -3 -p -r1.1 MouseEvent.java
*** MouseEvent.java	2000/04/09 04:13:27	1.1
--- MouseEvent.java	2000/06/27 19:58:47
*************** public class MouseEvent extends InputEve
*** 47,66 ****
  
    public Point getPoint ()
    {
!     Point p = ((Component) source).getLocation ();
!     p.x = x - p.x;
!     p.y = y - p.y;
!     return p;
    }
  
    public int getX ()
    {
!     return x - ((Component) source).getX ();
    }
  
    public int getY ()
    {
!     return y - ((Component) source).getY ();
    }
  
    public boolean isPopupTrigger ()
--- 47,63 ----
  
    public Point getPoint ()
    {
!     return new Point (x, y);
    }
  
    public int getX ()
    {
!     return x;
    }
  
    public int getY ()
    {
!     return y;
    }
  
    public boolean isPopupTrigger ()


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]