• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Undo Draw rect

 
Mohamed Farouk
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends
I have an image in a panel where i try ot draw a rect over the image the the rectangle gets drawn properly. Now i want to clear the rect which was created just now is it possible?

Thanks
Farouk
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is more of a GUI question, not an applet question, so I'm moving it to our AWT/Swing/GUI forum. Please find the thread there and continue the discussion.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would define a component to have an image and a rectangle, and have its paintComponent method render them both. To cause the rectangle to disappear set it to null:
 
Mohamed Farouk
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jeff
Thank you very much for your reply, now I am not sure how to do this can you give me an small code example. My component is a panel currently which in its paint method draws the image and this rectangle currently is drawn on the panel graphics is the mouse dragged along now how can i make the change you mentioned in this scenario?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic