0

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!

5
Contributors
6
Replies
8
Views
10 Years
Discussion Span
Last Post by PersonalIT
0

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.

0

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?

0

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 by ikeoddy: n/a

0

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

0

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 by PersonalIT: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.