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


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

Re: Could this be done better

From Knute Johnson <eternal@knutejohnson.com>
Newsgroups comp.lang.java.programmer
Subject Re: Could this be done better
Date 2014-11-24 16:26 -0800
Organization A noiseless patient Spider
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>

Show all headers | 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