Well, the easy answer is that you extend the abstract Graphics and provide implementations for the abstract methods. I expect that this is not what you meant. You can create another graphics from an existing graphics using the create method.
From the API: create public Graphics create(int x, int y, int width, int height) Creates a new Graphics object based on this Graphics object, but with a new translation and clip area. The new Graphics object has its origin translated to the specified point (x, y). Its clip area is determined by the intersection of the original clip area with the specified rectangle. The arguments are all interpreted in the coordinate system of the original Graphics object. The new graphics context is identical to the original, except in two respects: The new graphics context is translated by (x, y). That is to say, the point (0, 0) in the new graphics context is the same as (x, y) in the original graphics context. The new graphics context has an additional clipping rectangle, in addition to whatever (translated) clipping rectangle it inherited from the original graphics context. The origin of the new clipping rectangle is at (0, 0), and its size is specified by the width and height arguments. Parameters: x - the x coordinate. y - the y coordinate. width - the width of the clipping rectangle. height - the height of the clipping rectangle. Returns: a new graphics context. See Also: translate(int, int), clipRect(int, int, int, int)
However I have the funny feeling that you are REALLY asking how to get images into you GUI's
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: Nov 27, 2000
Thanks Cindy, Sorry I have asked wrong question? I meant to ask that Without creating or initiating Graphics objects , can I just access FontMetrics or getFont method in class(not in applet)? I solved this question myself. Thanks again, Angela
Hi angela, Without creating or initiating Graphics objects , how can I just access FontMetrics or getFont method in class(mine is a servlet and nota class/applet)? It seems you hae figured that out. Please let me know too. Than you, tarun
Joined: Nov 27, 2000
I used FontMetrics fontMetrics = applet.getFontMetrics(f); Where f is object variable of Font class Thanks angela
Originally posted by tarun Mehra: Hi angela, Without creating or initiating Graphics objects , how can I just access FontMetrics or getFont method in class(mine is a servlet and nota class/applet)? It seems you hae figured that out. Please let me know too. Than you, tarun
Joined: May 30, 2001
hey angela, Thanx a bunch. I just never realised that there was a getFontMetrics method for the component class. And all this time I thought that it could be applied only to Graphics objects. This really solved my problem. Thank you, I appreciate it. tarun.