> Suppose I want to make a Swing component that contains objects that
> need to show selection effects and control handles (e.g. resize or
[quoted text clipped - 7 lines]
> selection related stuff in paintComponent; handles etc. appear in front
> of children.
You could do something like that. IIRC, you'll need to switch optimised
drawing off.
> * Selection stuff gets added as children, which may present a
> management headache but keeps paint from needing to be overridden.
Headache is the important word in that sentence.
> * Something I haven't thought of yet.
My initial reaction is to go for a JLayeredPane.
> Also, should such a component subclass JComponent directly, or JPanel
> or even JScrollPane or similar?
If you have child components that appear to the user as components, use
JPanel as accessibility will be correct. The commonly held belief that
JPanel automatically sets opaque is not true of all versions of all
PL&Fs. JScrollPane isn't going to be easy to extend in a meaningful manner.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Twisted - 29 Mar 2006 18:10 GMT
So it's better to subclass JPanel (or JLayeredPane? Must investigate
that) and, if necessary, put it in a scroll pane as a child?
Monique Y. Mudama - 29 Mar 2006 19:30 GMT
> The commonly held belief that JPanel automatically sets opaque is not
> true of all versions of all PL&Fs.
Uhoh! Could you please elaborate?

Signature
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Thomas Hawtin - 29 Mar 2006 20:44 GMT
>> The commonly held belief that JPanel automatically sets opaque is not
>> true of all versions of all PL&Fs.
>
> Uhoh! Could you please elaborate?
The relevant setOpaque call comes from the PL&F, and is not set from
within the JPanel itself. IIRC, GTK on 1.5 is an example of a PL&F that
sets the opaque property to false. But not on 1.6.
When you set a JPanel as the content pane of a JFrame, technically you
should call setOpaque on it to avoid potential performance problems.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Monique Y. Mudama - 30 Mar 2006 20:15 GMT
>>> The commonly held belief that JPanel automatically sets opaque is
>>> not true of all versions of all PL&Fs.
[quoted text clipped - 8 lines]
> you should call setOpaque on it to avoid potential performance
> problems.
I did not know that. Thank you.

Signature
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html