Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #653
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail |
|---|---|
| From | Lew <noone@lewscanon.com> |
| Newsgroups | comp.lang.java.help |
| Subject | Re: Why can one invoke setters and getters from a (class) constructor? |
| Date | Mon, 25 Apr 2011 15:14:03 -0400 |
| Organization | albasani.net |
| Lines | 24 |
| Message-ID | <ip4h5p$v3n$1@news.albasani.net> (permalink) |
| References | <87bozwkgz8.fsf@merciadriluca-station.MERCIADRILUCA> <0na8r6tg38fu60ojepfl5h4u20lmhfhffr@4ax.com> <fd44b4d4-872d-442c-93d3-a80761ac19ae@w9g2000prg.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.albasani.net o3EbpQIPbdoiZYisH15ssf5GTGXV4qMQvxamzCV8XWuWQWh8cpT2komyVes0monCDyyQJZoP3IifFuojhs4sV1ZYPKb3isinmp7PbKmajVIBTX0sD5eqZygI2TlD95tt |
| NNTP-Posting-Date | Mon, 25 Apr 2011 19:14:01 +0000 (UTC) |
| Injection-Info | news.albasani.net; logging-data="jRSHUugtWGM8JoY1O2MKRDZMkvNZB1UBzVepI1JNgJdtGj3WMT0Z5fvxrv3EUQRn0noBhPor8ghUxms9kPrm0XdeB6zJZJn4EyZ2Mp8RrUH+GSc/TIrcm1ZRqmOrOEcg"; mail-complaints-to="abuse@albasani.net" |
| User-Agent | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 |
| In-Reply-To | <fd44b4d4-872d-442c-93d3-a80761ac19ae@w9g2000prg.googlegroups.com> |
| Cancel-Lock | sha1:Z+deEeWPi3uC9CLdfsbp2dSr0sw= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.help:653 |
Show key headers only | View raw
Fred wrote: > However, it can be dangerous for a constructor to call any method that > a subclass might override, because the superclass constructor would > then invoke the subclass method BEFORE the subclass constructor has > been called, and the subclass method may try to operate on subclass > variables that have not yet been created. > > Examples: Swing's JComponent constructor calls setBackground() and > setFont(). But if your component that is a subclass of JComponent is a > container that creates many other subcomponents, you might want your > setBackground() method to change the backgrounds of itself and all of > its subcomponents. But the JComponent constructor will invoke your > setBackground() before your constructor has created any of those > subcomponents. > > When I write constructors, they NEVER call any method that is not > private. or 'final' -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.help | Previous | Next — Previous in thread | Find similar
Why can one invoke setters and getters from a (class) constructor? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-23 19:36 +0200
Re: Why can one invoke setters and getters from a (class) constructor? Lew <noone@lewscanon.com> - 2011-04-23 13:58 -0400
Re: Why can one invoke setters and getters from a (class) constructor? markspace <-@.> - 2011-04-23 11:00 -0700
Re: Why can one invoke setters and getters from a (class) constructor? Merciadri Luca <Luca.Merciadri@student.ulg.ac.be> - 2011-04-23 23:53 +0200
Re: Why can one invoke setters and getters from a (class) constructor? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-04-23 20:36 -0400
Re: Why can one invoke setters and getters from a (class) constructor? Lew <noone@lewscanon.com> - 2011-04-23 22:37 -0400
Re: Why can one invoke setters and getters from a (class) constructor? Roedy Green <see_website@mindprod.com.invalid> - 2011-04-24 06:53 -0700
Re: Why can one invoke setters and getters from a (class) constructor? Fred <fred.l.kleinschmidt@boeing.com> - 2011-04-25 11:06 -0700
Re: Why can one invoke setters and getters from a (class) constructor? Lew <noone@lewscanon.com> - 2011-04-25 15:14 -0400
csiph-web