Drawing the Final Image


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.



    Java After Hours(c) 10 Projects You'll Never Do at Work
    Java After Hours: 10 Projects Youll Never Do at Work
    ISBN: 0672327473
    EAN: 2147483647
    Year: 2006
    Pages: 128

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net