This topic discusses classes found in the com.ibm.ivj.examples.vc.propertyeditors package.You can try this editor from either PersonTester or PaintTester.
The phoneNumber property has a text-based 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.
public class PhoneNumberPropertyEditor extends java.beans.PropertyEditorSupport { public void setAsText(String text) throws java.lang.IllegalArgumentException { if ((text.length() == 8) && (text.charAt(3) == '-' )) { setValue(text); return; } if (text.length() == 7) { setValue(text.substring(0,3) + "-" + text.substring(3,7)); return; } throw new java.lang.IllegalArgumentException(text); } }
The setAsText( ) method accepts only values that meet its format criteria; otherwise, it throws an IllegalArgumentException.
Property Editor Examples
Tag-Based Editor for the Person Bean
Custom Editor for the Person Bean
Paintable Editor for the Person Bean