Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30404

Re: Could this be done better

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Knute Johnson <eternal@knutejohnson.com>
Newsgroups comp.lang.java.programmer
Subject Re: Could this be done better
Date Mon, 24 Nov 2014 16:26:19 -0800
Organization A noiseless patient Spider
Lines 42
Message-ID <m50ias$fj7$1@dont-email.me> (permalink)
References <87zjbg97c5.fsf@Equus.decebal.nl> <m4vf1f$j03$1@dont-email.me> <m4vpb5$9ue$1@dont-email.me> <87bnnw6vo1.fsf@Equus.decebal.nl>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Tue, 25 Nov 2014 00:26:04 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="aba33539224e5c782fe0c4053f7756fd"; logging-data="15975"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Gf3RhwEBLF/GHRSplutXg"
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
In-Reply-To <87bnnw6vo1.fsf@Equus.decebal.nl>
Cancel-Lock sha1:jrBNtX8HrRCtO+Vm3cP5AYyplYg=
Xref csiph.com comp.lang.java.programmer:30404

Show key headers only | View raw


On 11/24/2014 15:11, Cecil Westerhof wrote:
> Op Monday 24 Nov 2014 18:19 CET schreef Knute Johnson:
>>  From the docs, JFrame:
>>
>> "As a convenience, the add, remove, and setLayout methods of this
>> class are overridden, so that they delegate calls to the
>> corresponding methods of the ContentPane. For example, you can add a
>> child component to a frame as follows:
>>
>> frame.add(child);"
>>
>> so you can skip the call to getContentPane().

That was my mistake, I was looking at the wrong line.

Another way around that is to extend JComponent rather than JFrame and 
add the component to the frame.  For a while people were fairly adamant 
about not extending JFrame but that's worn off a little lately.  I often 
extend JFrame for simple programs.  It used to be that we thought we 
might run some of them in applets but not so much any more.

>
>> Very small nit: The frame title is a parameter of the constructor.
>> You could have used:
>>
>> super(description)  as the first line.
>
> When I try that I get:
>      ColourCycling.java:10: error: cannot reference description before supertype constructor has been called
>              super(description);

The error on the super call is because description is local rather than 
a class field.

Have you looked at findbugs?  It's a really cool tool to find poorly 
designed code, orphans and other things.  Its free.

http://findbugs.sourceforge.net/

-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-24 12:16 +0100
  Re: Could this be done better "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-11-24 22:49 +1100
    Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-24 17:54 +0100
      Re: Could this be done better Knute Johnson <eternal@knutejohnson.com> - 2014-11-24 09:37 -0800
        Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-24 19:27 +0100
  Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-24 09:23 -0500
    Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-24 17:45 +0100
      Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-24 13:42 -0500
        Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-25 00:12 +0100
    Re: Could this be done better Knute Johnson <eternal@knutejohnson.com> - 2014-11-24 09:19 -0800
      Re: Could this be done better Knute Johnson <eternal@knutejohnson.com> - 2014-11-24 09:41 -0800
        Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-25 00:55 +0100
      Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-25 00:11 +0100
        Re: Could this be done better Knute Johnson <eternal@knutejohnson.com> - 2014-11-24 16:26 -0800
  Re: Could this be done better Brixomatic <brixomatic@yahoo.com> - 2014-11-25 19:58 +0100
    Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-25 14:36 -0500
      Re: Could this be done better Brixomatic <brixomatic@yahoo.com> - 2014-11-26 01:58 +0100
        Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-26 08:48 -0500
          Re: Could this be done better Brixomatic <brixomatic@yahoo.com> - 2014-11-29 19:43 +0100
            Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-29 15:44 -0500
              Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-29 15:47 -0500

csiph-web