I've been having problems with the now deprecated mouseDown and mouseDrag methods, I know the deprecation causes no problem, the program runs fine, but for grading purposes I want my program to be error and warning free, is there any EASY alternative that can solve this deprecation method? I know the method has been replaced by processMouseEvent but I've had a difficult time understanding the processing and stuff, the only thing I need is to register the position where the mouse was clicked down on the applet, thanks!

but for grading purposes I want my program to be error and warning free, is there any EASY alternative that can solve this deprecation method?

Read the updated api for mouse handlers I guess and follow suit.

I HAVE read the information on the official Sun site, but I don't exactly understand what I'm supossed to do, any chance anyone can provide me with an easy example of how the undeprecated (new) method works?

I've been having problems with the now deprecated mouseDown and mouseDrag methods, I know the deprecation causes no problem, the program runs fine, but for grading purposes I want my program to be error and warning free, is there any EASY alternative that can solve this deprecation method? I know the method has been replaced by processMouseEvent but I've had a difficult time understanding the processing and stuff, the only thing I need is to register the position where the mouse was clicked down on the applet, thanks!

Point clicked = null;
public void mousePressed(MouseEvent e)
{
clicked = e.getPoint(); // gives a Point object.
// To get the Point object in (x,y) coordinates
//do (clicked.x, clicked.y)
}

Hope this helps

Edited 6 Years Ago by ikeoddy: n/a

I've been having problems with the now deprecated mouseDown and mouseDrag methods, I know the deprecation causes no problem, the program runs fine, but for grading purposes I want my program to be error and warning free, is there any EASY alternative that can solve this deprecation method? I know the method has been replaced by processMouseEvent but I've had a difficult time understanding the processing and stuff, the only thing I need is to register the position where the mouse was clicked down on the applet, thanks!

For mouseDown see MouseListener (mousePressed)
For mouseDrag see MouseMotionListener (mouseDragged)

GL

To have a mouseDown procedure, one must implement a MouseListener interface (in java.awt.event).
mouseDrag is similarly implemented via a MouseMotionListener, also in java.awt.event.

However, to have the ability to both detect clicks and movement (quite helpful, really), one must use a different interface.

include javax.swing.event.MouseInputListener (details here)
Note that this is in javax, not java.
Then, define procedures for all the events:
mouseClicked
mouseEntered
mouseExited
mousePressed
mouseReleased
mouseDragged
mouseMoved

The compiler should then not complain about deprecated methods.

Not quite as simple as you wanted, I know. But about as simple as I can find.

Edited 6 Years Ago by PersonalIT: n/a

This article has been dead for over six months. Start a new discussion instead.