Article View: borland.public.jbuilder.java.language
Article #7180Re: Interfaces and keyword THIS
From: CLG
Date: Mon, 09 Jul 2001 12:32
Date: Mon, 09 Jul 2001 12:32
62 lines
2666 bytes
2666 bytes
Thats the beauty of interfaces. You can implement them at the same time,
you can implement 100 other interfaces. as long as you implement the
necessary functions, passing the object as a representating of that
interface is legal. Its not like the object is too BIG to fit into the
inerface :)
--
Peace,
Carl L. Gilbert
http://www.rigidsoftware.com
ICQ 614395-currently stolen working to retrieve.
"Then said I, Wisdom [is] better than strength: nevertheless the poor man's
wisdom [is] despised, and his words are not heard." Ecclesiastes 9:16
"Dick Gerrits" <dgerrits@wvm.nl> wrote in message news:3b442242_2@dnews...
> Hello jbuilder.java.language people,
>
> Question about keyword "this". As I understood is the keyword this a
> reference to the current object.
> Suppose I extend a class from JApplet and implement the MouseListener
> interface like:
>
> public class Applet1 extends JApplet implements MouseListener{
> .....
> addMouseListener(this);
>
> public void MousePressed(MouseEvent e) {
> ...}
>
> }
>
>
> To the method "addMouseListener" you can pass an object reference to
> "MouseListener" (the interface).
> (documentation method details -> public void
addMouseListener(MouseListener
> l)
> In many examples I see that you can pass the COMPLETE "current object" by
> using the keyword "this"
> (as in my example), but the method expects (only) a reference to a
> MouseListener interface.
>
> My question is:
> How does this work. What makes this possible ("this" implemented the
> interface MouseListener, but
> it is a lot more !).
>
> Thank you in advance for your explanation.
>
> Regards.
>
> B.V. Metaalwarenindustrie
> Witte van Moort
> Dick Gerrits
> dgerrits@wvm.nl
>
> -0-0-0-0-0-0-
>
>
Technical Details
Message-ID:
<3b49a595$1_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-out.nibble.net!news-in.nibble.net!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3b442242_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,91856323fbe3307a X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-07-09 05:41:02 PST From: "CLG" <lamont_gilbert @ rigidsoftware.com> Newsgroups: borland.public.jbuilder.java.language References: <3b442242_2@dnews> Subject: Re: Interfaces and keyword THIS Date: Mon, 9 Jul 2001 08:32:56 -0400 Lines: 64 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 24.181.226.14 Message-ID: <3b49a595$1_1@dnews> X-Trace: dnews 994682261 24.181.226.14 (9 Jul 2001 05:37:41 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-out.nibble.net!news-in.nibble.net!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews