Using processMouseEvent instead of mousedown?

S

Sanny

I was using mousedown() As Below.

----------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
public boolean mouseDown(Event evt, int x,int y){

----- OLD CODE
----- OLD CODE
return true;
}
----------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Above code works correctly. Now I found somewhere mousedown is
depriciated. And I thought of changingf to

processMouseEvent() fiunction

I used below Code. And replace mousedown() by
processMouseEvent(MouseEvent event)

NEW CODE
---------------

----------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

public void processMouseEvent(MouseEvent event) {

int x=event.getX();
int y=event.getY();

----- OLD CODE
----- OLD CODE
super.processMouseEvent( event );
}
----------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


The new code do not give any compilation error. But when I start the
Applet the mousedown is not working.

Q 1. Do I have to add something more to use mouse pressed events?

Q 2. What is the benefit of using processMouseEvent() instead of
mousedown()?

Bye
Sanny
 
A

Andrew Thompson

The new code do not give any compilation error. But when I start the
Applet the mousedown is not working.

Maybe it is just tired. Give it a good night's
rest and call me in the morning.
Q 1. Do I have to add something more to use mouse pressed events?

That depends (on the code not shown).

An SSCCE helps to explain code very well.
<http://pscode.org/sscce.html>

Please be specific*, and try to frame a 'smart question'**.

Q 2. What is the benefit of using processMouseEvent() instead of
mousedown()?

It is not deprecated.
 
J

Joshua Cranmer

Sanny said:
I was using mousedown() As Below.

----------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
public boolean mouseDown(Event evt, int x,int y){

----- OLD CODE
----- OLD CODE
return true;
}
----------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Above code works correctly. Now I found somewhere mousedown is
depriciated. And I thought of changingf to

Event handling between the early versions of Java and modern versions
changed, drastically. With something this big, I'd recommend reading the
Java Tutorial on GUIs again.

What you want to be using now is the event handling mechanisms using
MouseListener and friends.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top