File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Moving graphics and text over an image Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Moving graphics and text over an image" Watch "Moving graphics and text over an image" New topic
Author

Moving graphics and text over an image

Gary Hodge
Greenhorn

Joined: May 20, 2005
Posts: 3
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

Joined: Jan 14, 2004
Posts: 1535
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

Joined: May 20, 2005
Posts: 3
thanks, i get it, so i would repaint as the drag occurs.

how do i go about making the balloon resizable?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Moving graphics and text over an image
 
Similar Threads
add/remove components by timer
Move enlarged image around on mouseover - Image mapping
JTextArea image
WA #1.....word association
How to Write Text over an existing image