Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Graphics problem , how to approach ?

 
Tirthankar Mukherjee
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to repaint a component. Putting a image on a panel the applying graphics change in it (like drawing polygon, rectangle ..).


I would like to take the backup of the image passed to the class, and restore the graphics of the Component on need.

Problems I am facing :

1) Cannot make a clone for Image class.
2) Taking the backUp in BufferedImage using

3) Trying to restore the image with


seems not working.

NB : repaint() is always there.

Thanks in advance.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
drawImage(..) the original image to the Graphics context of the backup image.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tirthankar Mukherjee wrote:
3) Trying to restore the image with

You do realize that after that line executes, you have two references to the same BufferedImage, don't you?

Also, I can't see why a cast to Image would be needed. What's the Type of imageBackUp?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic