At the very end of the paint method, the code draws the internal image on the screen, if the user is not dragging the mouse. If the user isn't dragging the mouse, the image has been finalized, which is why Painter draws the image object onscreen. After drawing the image, Painter also refreshes the black rectangle outlining the image in Painter's window, which you need to do in case the window was minimized and then restored or in case an overlapping window was moved: if(!dragging){ g.drawImage(image, offsetX, offsetY, this); } g.setColor(Color.black); g.drawRect(offsetX, offsetY, imageWidth, imageHeight); } There's one last task to coverletting the user select the drawing color. |