Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 01 Mar 2013 14:53:02 -0600 Date: Fri, 01 Mar 2013 22:52:42 +0200 From: Donkey Hottie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: quick question References: <23b84c9f-ada5-4d99-9aa5-d291dd14b312@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: Lines: 57 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-bxcDs/9cRTjp77JDHzz5ZkYWrUfauePMn8b6+0e2V9nr8C8yfz6fsbaxIFW6A/oV1AFaZH/HnpLilML!8O/wr2x1h0j6wOd5mzjw+pf7cV7FssDjahlmv9Hbtt7SsQonfBwuao2FtUadFRS5ZfAL X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3109 Xref: csiph.com comp.lang.java.programmer:22662 01.03.2013 21:08, Daniele Futtorovic kirjoitti: > On 01/03/2013 19:48, Eric Sosman allegedly wrote: >> On 3/1/2013 1:25 PM, Doug Mika wrote: >>> reading a book a came upon the following inside a 'myDialog extends >>> JDialog" class inside an actionlistener implemented as an anonymous >>> inner class. >>> >>> myDialog.this.dispose() >>> >>> why not simply write >>> >>> this.dispose() >> >> That would be perfectly all right, if you get your thrills >> from reading the compiler's error messages. :) >> >>> does it have anything do with the fact that this line is found within >>> an anonymous inner class that is an actionListener? >> >> Yes. An unadorned `this' would refer to the instance of the >> class whose code is running. That's the anonymous class that >> implements ActionListener, a class that doesn't even *have* a >> dispose() method (unless one's been added explicitly in the >> anonymous class, which would be awfully strange). >> >> Writing `this.dispose()' or simply `dispose()' would try >> to call the anonymous class' dispose() method, not any method >> belonging to the enclosing myDialog (poor choice of name, BTW). >> The intent, most likely, is to close the dialog -- so the code >> uses `myDialog.this' to mean "Not *this* `this', but the `this' >> of the enclosing class named `myDialog'." It's that enclosing >> class' dispose() that's being called. >> > > For the record, it's called a "Qualified 'this'", and the specification > can be found here: > > This "Qualified this" is kind of hard to understand. How myDialog.this.dispose() differs from myDialog.dispose() If myDialog is an object instance, would't it be sufficient just call dispose it? -- "Unfortunately suspend does mean things sometimes" Husse Apr 25 2007