Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Moving, Dragging, Resizing Images in Canvas  RSS feed

Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am having problem in giving the functionality for Dragging, Resizing of images in Canvas.
Actually , I have drawn an image in canvas & now I want that it should be able to be selected by user so that he can resize it , shear it, rotate it etc.
I am trying Graphics2D for it.
I have modified paint method of my canvas class as below :
public void paint(Graphics g) {
System.out.println("In paint of RefreshCanvas");
int w = 25;
int h = 20;
Graphics2D g2 = (Graphics2D)g;
AlphaComposite ac = AlphaComposite.getInstance (AlphaComposite.SRC_OVER,(float)0.8);

if(img==null || img.size()<1) { }
else {
System.out.println("Image found");
for(int i=0; i<img.size(); i++)
if (RText==null || RText.trim().length()<1) {
} else {
g2.setStroke(new BasicStroke(5.0f));
In above code img is the Vector containing Image objects & RText is the text message entered by user.
With the above code, I am able to display multiple overlapping images & also
some text over it.
But what I want that user should be able to select any of images & can resize, reshape and/or drag it. (A bit similar to as we can select image (Object) in MS PowerPoint and can replace & resize it).
Can anybody help/guide me in achieving this functionality.
Thanks & Waiting for some input.

Manoj Tyagi

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!