Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java2D and Dragging Images

 
Larry Eisenstein
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic