This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi I am using a JPanel (with double buffering on) to draw lots of shapes like lines, circles etc. When the user draws another shape, it is drawn over the existing shapes and a repaint for all shapes has to be called. Is it possible that the temporary/intermediate shapes being drawn on the shape do not overwrite / erase the underlying graphics. I want that the underlying graphics should be always visible. Also, it is possible that I have to draw more than one shapes in the temporary phase. Thanks in advance. Amit
Hi Amit, Make sure you are overridding the Update method to avoid the erasing stage of painting.
Joined: May 09, 2001
Hi Manfred, COuld you please elaborate on the exact use of the update() method. Also, i cannot avoid the erasing stage completely. I need to erase the temporary shapes that I make and at the same time keep the original shapes in the background. e.g. drawing a line with a mouse drag would require to draw an new line and erase the old line with the dragging. Also, is it possible to place an invisible / transparent panel over the background panel that can be repainted without the need of repainting the background panel and also keeping the graphics on the background intact? Amit
Hi there i dont know any way to erase the last drawed shape without demeged to underline shape. by ovrriding the update() like you did you can avoid the screen the clear itself. a partial solution is to move the clearing rect to your last drowed shape like this :
in this way only the last shape will be erased but what was under it will be erase as well. if you diside to go forther think about multiple panels and usinf of setVisible(true/false) it may provide kind of solution. best regards Shay Gaghe