BUG in jre that work fine in jview - mouseEvent  
Author Message
EdisonCPP





PostPosted: 2005-1-7 22:34:00 Top

java-programmer, BUG in jre that work fine in jview - mouseEvent Anyone come up with an answer to this?
I'm having the same problem, I've created
a "skin" slider control in J++, when I use
Microsoft it returns coordinates relative to
the slider control, when I use Sun it's relative
to the applet, the listener class and handler is
within the slider control class.

I've found LOTS of examples online that are setup
just like my code, and they all, including Sun's
documentation (as well as Microsoft's) say it should
be relative to the control.

Thanks,
EdisonCPP

Nir melamoud wrote:
> Hi,
>
> Can anyone please explain me how can i write an application that
> use the mouseEvent.getX(),mouseEvent.getY() functions on both sun jre
> and microsoft jview without checking for the interpreter origin ?
>
> In jview the function return the coordinate relative to the component
top
> left point = (0,0)
>
> In jre it return in mouseEnter relative to the beginning of the
screen (not
> even the window)
> and in mouseExit relative to the component top left point ?
>
> It look like a bug in jre, because sun help support microsoft version
-
> relative to the source component.
>
> Does anyone know how can i translate these points so it will work on
both
> jview and jre ?
>
> here is a small code example: try to enter and exit the frame and see
the
> printout, try it on jre and jview
>
> import java.awt.* ;
> import java.awt.event.* ;
> import java.io.*;
> import jclass.bwt.*;
>
> class mouse extends Frame {
> public static void main(String arg[]) {
> mouse m = new mouse("Mouse Test") ;
> m.setSize(400,300) ;
> m.setVisible(true);
> }
>
> public mouse(String s) {
> super(s) ;
> enableEvents(AWTEvent.MOUSE_EVENT_MASK);
> }
>
> public void processMouseEvent(MouseEvent m) {
> System.err.println("x,y = " + m.getX() + "," + m.getY()) ;
> }
> }