The simple answer is just to call repaint() on the sub-component of the applet. ( For example, if you have a Canvas called imageCanvas1 that you want to repaint without repainting the entire applet, you could call it's repaint() method directly by calling :
) However, this solution is not as simple as it seems... if you do anything that would cause the sub-component to change size, or change location on the screen, you will need to call doLayout() on the component that holds your sub-component... and doLayout() forces a repaint() to be called on the component that doLayout() is called on, and on all the sub-components of that component. So the answer is, for small changes, simply calling repaint() on a sub-component will work, but for most things you cannot get away with not doing a repaint of the top level GUI element. I'm sure that if this is a big problem for you, you can find some way around it, like creating a Panel big enough to hold the maximum size of all your sub-components and then calling doLayout() on that Panel instead of the applet... but I am not sure if that is any better because all your sub-components get painted anyway... Anyway, here's some code that I used to test this out... all you need to do to see what is going on is to replace the two images I was using ( washu and abbey ) with images of your own, and then comment and uncomment lines to see what goes on...
Enjoy! HTH, -Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Devious Experiments for a Truly Passive Greenhouse!