• Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving graphics and text over an image

 
Gary Hodge
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking for suggestions or sample code for how to move a balloon with text in it over an image.

By balloon, I mean a caption such as that seen in a comic strip. I have figured out how to use the Graphics2D class to draw the balloon as a RoundRect and a GeneralPath triangle. I have written text over the balloon using drawString.

I want to be able to move the balloon (and its text) over the image, to resize the balloon and to edit the text inside the balloon.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Send in the new coordinates for the 'balloon', set them in the graphic component and 'repaint' the component. You can generate the new location coordinates with mouse code or with animation (thread/swing timer) event code. The main idea is to expose the variables (as instance variables) that you want to be able to set from outside the graphic component and manipulate these (either directly or via 'setter' methods) from within your event code (eg, calling 'moveBalloon' from inside 'mouseDragged') to get the graphic effects you want.
 
Gary Hodge
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, i get it, so i would repaint as the drag occurs.

how do i go about making the balloon resizable?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!