> I do it like this:
>
[quoted text clipped - 21 lines]
> rendered in the JList.
> What wrong?
Not clear what you're trying to achieve.
A Renderer is a component that is never really "present" in the
component hierarchy. When the list is being painted, the renderer is
added temporarily (not even directly - but that's an implementtion
issue) , placed at the appropriate location, is asked to paint itself,
and removed immediately thereafter. So what you see on screen is not
really the component itself - but just what it painted. You cannot
therefore expect it to react to user inputs and change state.
If what you want is an editable JList with a JCheckbox as the editor,
use a JTable with a single column, and use a JCheckBox as its
*CellEditor* (not Renderer).
BK
MaoXuePeng - 14 Oct 2004 14:31 GMT
Thank you,BK.
I want to make the check box which rendered on the JList editable, but
failed.
> So what you see on screen is not
> really the component itself - but just what it painted. > You cannot
> therefore expect it to react to user inputs and change
> state.
> If what you want is an editable JList with a JCheckbox as > the editor,
> use a JTable with a single column, and use a JCheckBox as > its
> *CellEditor* (not Renderer).
I think you are right. I am to try it and post the answer later.
Regards!
MaoXuePeng.
> I do it like this:
The 'tame' swing examples has a version that works as you want.
<http://www.physci.org/codes/tame/>
Follow the links to the launcher applet and check 'CheckListExample'
and 'CheckListExample2' to see them, follow the 'Launchet' link
from the top of the page, the drop-down menu shows the source.
HTH

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane