This topic discusses classes found in the com.ibm.ivj.examples.vc.propertyeditors package.You can try this editor from PaintTester only.
The sex property has a paintable editor associated with it. This editor extends java.beans.PropertyEditorSupport, a concrete implementation class for the java.beans.PropertyEditor interface. As a result, setValue( ) does not have to be implemented locally. In this type of property editor, we paint the tagged value back into the property sheet instead of returning it as a String.
public class SexEditor extends java.beans.PropertyEditorSupport {
public String[] getTags() {
String[] tags = {"male", "female"};
return tags;
}
public boolean isPaintable() {
return true;
}
public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) {
String tString = getAsText();
if (tString.equals("male") )
gfx.setColor(java.awt.Color.blue);
else
gfx.setColor(java.awt.Color.magenta);
gfx.drawString(tString, (box.x) + 1, (box.y) + (box.height) - 2);
return;
}
}
The getTags( ) method holds allowable property values in an array. Instead of using getAsText( ) and setAsText( ) as we did for IncomeRangeEditor, we override isPaintable( ) and paintValue( ). The resulting property sheet looks like this:

Property editor examples
Tag-based editor for the Person bean
Text-based editor for the Person bean
Custom editor for the Person bean