|
From: Rogan D. <ro...@da...> - 2008-01-28 21:24:07
|
Arne Limburg wrote:
> Hi Rogan,
>
> you need to extend AsYouTypeTextComponentAdapter and override
> adaptedValueChanged with something like this:
> protected void adaptedValueChanged(Object newValue) {
> super.adaptedValueChanged(((String)newValue).getBytes());
> }
>
> You also have to reimplement TextComponentBinding to use your Adapter
> and to set the bytes, i.e. you have to change line 41 like this:
> textComponent.setText(new
> String((byte[])valueModel.getValue()));
>
> and implement an appropriate Binder (take a look at TextAreaBinder).
> <http://dict.leo.org/ende?lp=ende&p=eL4jU.&search=appropriate>Of course,
> if you need you have to handle encoding-specific conversions at the
> places above.
>
> Regards,
>
> Arne
I was looking at TextComponentBinding.java, and noted the Exception
handling:
protected JComponent doBindControl() {
final ValueModel valueModel = getValueModel();
try {
textComponent.setText((String) valueModel.getValue());
}
catch (ClassCastException e) {
IllegalArgumentException ex = new
IllegalArgumentException("Class cast exception converting '"
+ getProperty() + "' property value to string - did you
install a type converter?");
ex.initCause(e);
throw ex;
}
// TODO: implement ValueCommitPolicies
new AsYouTypeTextComponentAdapter(textComponent, valueModel);
return textComponent;
}
Would it not be sufficient to make an appropriate type converter?
Rogan
>
> Rogan Dawes schrieb:
>> Hi folks,
>>
>> I'd like to represent a byte[] field as a String in a JTextArea.
>>
>> Can anyone explain how to create such a Binder/Binding?
>>
>> Thanks
>>
>> Rogan
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> Springframework-rcp-dev mailing list
>> Spr...@li...
>> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev
>>
>>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Springframework-rcp-dev mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev
>
>
|