aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Java2D and Dragging Images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java2D and Dragging Images" Watch "Java2D and Dragging Images" New topic
Author

Java2D and Dragging Images

Larry Eisenstein
Greenhorn

Joined: Feb 21, 2006
Posts: 14
I've trying to learn some Java2D/GUI and as a little "test project", I am creating an applet that looks like a line graph. Each "Bar" is just a line(10 px wide) and I have drawn an arrow.gif on the end of each line.

When I drag the arrows, the line should grow and shrink.
Problem:
When I click on it, the mouse positions itself to the far "left" edge of the image. So, I have no issues dragging the line to the right.

But, when I drag to the left, I run into problems. If I drag too fast, the pointer gets off the image and the dragging stops(b/c the onImage method returns null).

I've tried creating a larger bounding box for the image, and that helps a little, but I still have issues when I drag too fast.

Anyone have any ideas how to get around this?

|
|----------------->
|
|------------->
|
|------->
|
|=======================



Thanks
Larry Eisenstein
Greenhorn

Joined: Feb 21, 2006
Posts: 14
I found the answer to some of the issues is anyone runs into something similar.

1. I just made the bounding rectangle around the image bigger.
2. I double buffered the applet
Great tutorial on Double Buffering: http://www.developer.com/tech/article.php/626541

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java2D and Dragging Images