Mouse Events

i have a program which have deprecated
Mouse Events

Please take a look:

  public boolean mouseMove(Event event, int i, int j)
    {
        if(j <= iRowHeight)
        {
            int k = i;
            i = (i + iX) - iGridWidth;
            int l;
            for(l = iColCount - 1; l >= 0; l--)
            {
                if(i > -7 && i < 7)
                    break;
                i += iColWidth[l];
            }

            if(l >= 0)
            {
                if(!bDrag)
                {
                    setCursor(11);
                    bDrag = true;
                    iXDrag = k - iColWidth[l];
                    iColDrag = l;
                }
                return true;
            }
        }
        return mouseExit(event, i, j);
    }


how can i change to the new method?
processMouseEvent(MouseEvent e)??
Please help
Clement

LVL 1
opabcAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OviCommented:
Let's say you have a Canvas on wich you want to implement this method. You will do something like this :

Canvas c = new Canvas;
c.addMouseMotionListener(new MouseMotionAdapter() {
      public void mouseMoved(MouseEvent e) {
      // your code here
int i = e.getX();
int j = e.getY()
       if(j <= iRowHeight)
                            {
                                int k = i;
                                i = (i + iX) - iGridWidth;
                                int l;
                                for(l = iColCount - 1; l >= 0; l--)
                                {
                                    if(i > -7 && i < 7)
                                        break;
                                    i += iColWidth[l];
                                }

                                if(l >= 0)
                                {
                                    if(!bDrag)
                                    {
                                        setCursor(11);
                                        bDrag = true;
                                        iXDrag = k - iColWidth[l];
                                        iColDrag = l;
                                    }
                                    return true;
                                }
                            }
      }
});


Using MouseMotionAdapter let you implement only mouseMoved method if you want to. If you use MouseMotionListener instead, you will be forced to implement both mouseMoved and mouseDragged metods.

Good luck.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
opabcAuthor Commented:
I still dun understand
can u convert the entire code that i post to the new method processMouseEvent(MouseEvent e)??
0
OviCommented:
protected void processMouseEvent(MouseEvent e) Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects. This method is not called unless mouse events are enabled for this component. Mouse events are enabled when one of the following occurs: A MouseListener object is registered via addMouseListener. Mouse events are enabled via enableEvents. Parameters:e - the mouse event.Since: JDK1.1 (AWT help)


What Java are you using in your application? In awt, this method is protected wich meens your component inherit this method from his parent
and automatically execute'it on a mouse event to your component. Depending on the type of this event (mouseMove, mouseDragg, etc) he send this event to appropiate mouse listener to process'it. So my example is applicable in this case. For more details, please be more concrete about your code.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.