It jumps coz the size of image is too large and it takes your image to the mouse position whenever you try to drag it.
Hint: Let mouse drag the image if mouse is inside the image coordinates.
Type: Posts; User: Mr.777
It jumps coz the size of image is too large and it takes your image to the mouse position whenever you try to drag it.
Hint: Let mouse drag the image if mouse is inside the image coordinates.
1. Since your very first post, you are actually crying about getting your problem solved. No one here will actually solve your problem. We are here, not to do homework for anyone and neither any time...
Why don't you think this?
It's easy to get your problem solved. Try to solve it on your own. Try try again and think what it's doing now and what do you want it to do. It's zooming canvas, not...
For me this code works fine. And it doesn't behave as it behaved previously.
And your drawImage is working fine as you are only trying to draw image and it's working perfect. Well, i will recommend...
Read my above post. I've double posted, so read the second one.
public void mouseDragged(MouseEvent me) {
dx = me.getX() - x;
dy = me.getY() - y;
}
This is your current drag code, why are you subtracting x and y...
Well, i can not tell you, what to write but can guide you as forums rules don't allow to spoon feed. So, i can simply tell you one more thing, that your painComponent() function is drawing the image...
Okay let's say, in the very start, your image is at 0,0. Now when you drag it, you actually get image from 0,0 to start dragging. And when you released, you do nothing. You must get the current...
On mouse release you don't the current x,y coordinates of the image, so when you try to drag again, image jumps to it's original position to get dragged.
You are actually zooming the canvas, so it...