Hi guys,
I'm using Swing to create a JTable with one column rendering a checkbox
(Boolean). Fine, this works because I have a custom table model that
overrides getColumnClass() and now everybody is happy figuring out how to
render a Boolean.
Now I'm not happy with white background so I create a new renderer class,
and I myTable.setDefaultRenderer(Boolean.class, new BooleanClassRenderer().
Fine, now I get my pretty color background.
But ....... (the big but) that pretty background overwrites the checkbox
which is now hidden until you use the editor to MouseDown on the cell. Then
the checkbox appears visible until you MouseUp.
How is this happening and how can I prevent it? I've tried a number of
things like new Boolean(true) in the renderer *after* setting the
background. This has me stumped and I don't know where to look for help.
Any ideas?
hiwa - 29 Dec 2005 02:33 GMT
A stab in the dark:
Your cell renderer method doesn't return a check box.
jupiter49 - 29 Dec 2005 18:13 GMT
> A stab in the dark:
> Your cell renderer method doesn't return a check box.
Yep, I tried that. Same result. The JCheckbox is only visible is you
MouseDown on the cell.
I tried setBackground(Color.WHITE) and even that overwrote the checkbox. I
have to let the default renderer paint it or it just doesn't happen right.
I think I already tried extending default renderer and using
super.setBackground() but it was the same result.
hiwa - 30 Dec 2005 04:04 GMT
Smells your renderer code is wrong.