
Signature
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
> Reading books about software engineering and design patterns, I adopted
> the axiom ‘prefer delegation over inheritance’. However, I see that the
> Swing tutorials recommend to inherit from JFrame.
Are you sure? where?
http://java.sun.com/docs/books/tutorial/uiswing/components/frame.html
makes no such recommendation that I can see, the example has the class
contain a JFrame rather than extend it.
> The examples do it as well,
A lot of Sun's examples which I recall from when learning Swing, used a
CreateAndShowGUI() method which instantiates a JFrame directly.
> and in fact, a lot of apps I see do this.
>
> Is there a reason for this, or is this just old-fashioned thinking? Am
> I missing something?
I guess it is mostly old-fashioned thinking, some of the examples must
have been around a long time, with only minor changes. I expect some
examples, when illustrating some subject other than JFrame usage, extend
JFrame merely to reduce the linecount?
My understanding of the collected wisdom here is: just because two
JFrames contain different collections of widgets doesn't make them
different types of JFrame - at least not to the extent that you'd be
justified in subclassing JFrame.
> My app which *has* a JFrame works just fine.
All mine do too nowadays.

Signature
RGB
> Reading books about software engineering and design patterns, I adopted
> the axiom ‘prefer delegation over inheritance’. However, I see that the
[quoted text clipped - 3 lines]
> Is there a reason for this, or is this just old-fashioned thinking? Am
> I missing something? My app which *has* a JFrame works just fine.
As with so many other patterns, then you should only apply it when
appropriate.
I don't think JFrame is an obvious fit for that pattern.
Both extending and composing JFrame are frequently used.
And frequently discussed.
See http://forums.java.net/jive/message.jspa?messageID=224388 as
an example.
Arne