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.
Joined: Jan 14, 2004
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.
Joined: May 20, 2005
thanks, i get it, so i would repaint as the drag occurs.