🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7244

Interfaces and keyword THIS

#7244
From: Dick Gerrits
Date: Thu, 05 Jul 2001 08:15
41 lines
1888 bytes
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: <3b442242_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,91856323fbe3307a,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-07-05 01:20:56 PST
From: "Dick Gerrits" <dgerrits@wvm.nl>
Newsgroups: borland.public.jbuilder.java.language
Subject: Interfaces and keyword THIS 
Date: Thu, 5 Jul 2001 10:15:50 +0200
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 213.116.112.101
Message-ID: <3b442242_2@dnews>
X-Trace: dnews 994320962 213.116.112.101 (5 Jul 2001 01:16:02 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews