• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Moving graphics and text over an image

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic