This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Undo Draw rect Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Undo Draw rect" Watch "Undo Draw rect" New topic
Author

Undo Draw rect

Mohamed Farouk
Ranch Hand

Joined: Jun 08, 2005
Posts: 242
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


SCJP, SCWCD, SCBCD, SCEA 5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35440
    
    9
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.


Android appsImageJ pluginsJava web charts
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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:


There is no emoticon for what I am feeling!
Mohamed Farouk
Ranch Hand

Joined: Jun 08, 2005
Posts: 242
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

Joined: Sep 16, 2005
Posts: 1780
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Undo Draw rect
 
Similar Threads
draw rect problem?
draw rect problem?
Saving a Jpanel as a JPEG
Graphics - BufferedImage - ImageIO problem
Draw margin for Image