[4071] in java-interest

home help back first fref pref prev next nref lref last post

Re: [Q] getWidth(this), why passing 'this'?

daemon@ATHENA.MIT.EDU (Pradeep Badri)
Fri Dec 8 23:25:33 1995

From: Pradeep Badri <pbadri@cisco.com>
To: edith@pencom.com (Edith Au)
Date: Fri, 8 Dec 95 18:02:57 PST
Cc: java-interest@java.sun.com
In-Reply-To:  <9512081655.aa29746@china.pencom.com>; from "Edith Au" at Dec 8, 95 4:55 pm


Hi,

One of the elements in Applet inheritance hierarchy is the
Component class which implements ImageObserver and provides
a default implementation.  That's the reason why you could pass "this"
to getWidth() function.  You could override it if you want
your implementation.

cheers,
-pb.

Pradeep Badri.
Cisco Systems.

> 
> Hi,
> 
> public class a extends Applet
> {
> 	Image im;
> 
> 	public void init()
> 	{
> 		try 
> 		{
> 			im = getImage(/* an image */);
> 		}
> 		catch (Exception e) 
> 		{}
> 		
> 		imWidth = im.getWidth(this);
> 	}
> }
> 
>   According to the API, getWidth takes an ImageObserver object as a parameter.
> 'this' is an applet.  The only common ancestor of Applet and imageObserver is
> Object.  How come 'this' can be passed as an mageObserver?
> 
> -Edith
> -
> This message was sent to the java-interest mailing list
> Info: send 'help' to java-interest-request@java.sun.com
> 

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post