I have a couple of questions concerning the Graphics Context. Perhaps someone would be kind enough to help this newbie. It seems that whenever we want a graphics context we need to use getGraphics() rather than new Graphics(). I assume that this is because the Graphics object that is returned in the former is chock full of necessary info such as the clip region for the component, etc (the context part of "Graphics Context")... am I right in this assumption? But how does the Graphics context know which component we want it to be associated with? If I have a frame with two panels, how does the Graphics context know I want it to be associated with the first panel and not the second one? Thanks in advance Dan
Because you call getGraphics() on the component you want to get the graphics of! If you have a frame with two panels ( panel1 and panel2 ) panel1.getGraphics() gets the graphics context of panel1, panel2.getGraphics() gets the graphics contect of panel2, and getGraphics() gets the graphics context of the frame ( if your frame is your main class... )
You are pretty much right about the reason why there is no new Graphics() call... I think that it is also due to the graphics context dealing with alot of native resources...
-Nate [This message has been edited by Nathan Pruett (edited July 31, 2001).]
Write once, run anywhere, because there's nowhere to hide! - /. A.C.