java.beans.PropertyEditor.paintValue() from JComponent.paintComponent()?
- From: "ljnelson@xxxxxxxxx" <ljnelson@xxxxxxxxx>
- Date: 6 Nov 2005 19:16:12 -0800
Hello. I am attempting to put together a property sheet using a
JTable.
I understand the cell rendering and cell editing mechanics very well.
I am attempting to do this using java.beans.PropertyEditors where
possible, so that, for example, I can take advantage of the
sun.beans.editors.* classes. Also it just smells good; code reuse is a
good thing.
What I don't understand is how to pass the correct values to
PropertyEditor.paintValue(Graphics, Rectangle). More accurately, I
would like to know if the behavior I see from
sun.beans.editors.ColorEditor is correct or not.
As I understand it, PropertyEditor.paintValue(Graphics, Rectangle) is
probably intended to be called from some Component's paint(Graphics)
method, or, more likely in Swing's case, from JComponent's
paintComponent(Graphics) method. So that's what I'm doing.
I'm also guessing that since the JComponent in this case that will be
calling PropertyEditor.paintValue(Graphics, Rectangle) is a table cell
renderer, that it should simply pass Graphics.getClipBounds() for the
Rectangle argument. I have deduced from reverse engineering a lot of
the Sun code that the Rectangle is not supposed to be null, so I have
to supply something. It makes sense to me to supply the clip, whatever
it may be, and not the bounds of the component in question.
Does that make sense?
Anyhow, if I do this, I do indeed get a perfectly functioning property
sheet, and lo and behold the sun.beans.editor.ColorEditor code gets
invoked, and the table cell in this case turns a lovely shade of
green--but it's off by a couple pixels. That is, the bottom and right
edges are painted white, not green. It looks like a border problem,
but I don't think that's it.
Should I pass the clip rectangle (which would mean among other things
that sun.beans.editors.ColorEditor is buggy)? Or should I pass the
component boundaries itself and override paint() instead of
paintComponent()?
Thanks,
Laird
.
- Prev by Date: Re: Get data from external config file securely
- Next by Date: mozilla style sidebar
- Previous by thread: Unwanted lines in selected JTable row
- Next by thread: mozilla style sidebar
- Index(es):
Relevant Pages
|