How to write a text into a textarea that is not intended for modification?

I wanted to create a textarea, and I set an empty string as its value. After that, I set it as readonly, but somehow it does not work - is it ever possible to set any text as value of the textarea with the setValue() - method just to prevent modification of that text thereafter?

I have the impression that by just setting it as readonly after setting the value does not work :\

answerarea=new TextArea();
        answerarea.setValue("");
        answerarea.setReadOnly(true);
        answerarea.setWidth(360, UNITS_PIXELS);
        answerarea.setHeight(500, UNITS_PIXELS);
       
        if(gridlayout.getComponent(2,0)==null){
               gridlayout.addComponent(answerarea,2,0);
               gridlayout.setComponentAlignment(answerarea, Alignment.TOP_CENTER);
        }

if you have an UI Component and make it [ read only ]
wel … you can’t change it’s Value programaticlly or by user . if you did exception will be thrown [ Property.ReadOnlyException ]
.
so if you want a component shown for user that who can’t change it’s value but you can programmaticlly you can use

yourComponent.setEnabled(false); to set your component disabled .

for better see …
https://vaadin.com/book/-/page/components.features.html

I wish that is what you looking for !

THX 4 Your answer, well it actually was feasible, and yet, since it is awkward to display text on a diabled TextArea, in the stead of a TextArea, I now make use of a different component: I simply display everything on a Label, whose text cannot be changed, and whenever I want to have a new text, I set it by calling its setValue(“string”) method.