Calling setValue() on read only text field throws exception

In looking at the documentation for setReadOnly(), it implies that one could call setValue() programmatically:


The read-only status affects only the user; the value can still be changed programmatically, for example, with Property.setValue(Object).

However, when I try to do this, I get the read only exception. Is there a way to implement a text field for which the user cannot change the value, but the programmer can?

I could use setEnabled(false), but I don’t like the completely grayed out look.

I would say that Component.setReadOnly documentation simply is wrong. Property.setValue states that it throws Property.ReadOnlyException if the object is in read-only mode.

To change the value programmatically do

setReadOnly(false);setValue(“newValue”);setReadOnly(true);

Excellent workaround, thanks!!!