Hello everyone ,
I would like to wrap the string representing the caption of the label . How can I do?
Thanks in advance
Hello everyone ,
I would like to wrap the string representing the caption of the label . How can I do?
Thanks in advance
What do you mean by wrap the string?
I have a label with a caption.
Label l = new Label("Example of label");
l.setCaption("Example of a label that I would like \nto wrap");
I would that the web page was represented in this way:
Example of a label that i would like
to wrap. Example of a label.
Please see
https://vaadin.com/book/-/page/components.label.html
. This shows how to use \n by changing the ContentMode.
Ok thank you.
Now I try to do this, then I let you know.
I read the section on the label, and I tried this:
Label label= new Label(" This is the example of the first"+"\nHello");
label.setCaption("This is a caption \nfor my label");
label.setContentMode(ContentMode.PREFORMATTED);
The problem is that this works with the value of the label
(in my case with the String: “This is the example of the first Hello” ) and not with the caption that remains “This is a caption for my label” on one line.
Why set a caption for a label? What is your use case for this? Labels are most oftenly used as captions themselves. Anyways if you would like to wrap the Label’s caption, you must do it via CSS.
I’m doing this because I have a window that must contain non-editable values and each of these values must have a title or a description associated . Advice me an alternative way ?
I don’t know about your data. But for me, it’s much cleaner if the Caption is up to 2words only. The Value can be long and be wrapped. The Description should be placed via setDescription() method which will show a tooltip. I don’t like to overwhelm a user tons of data in a screen. This will be much more cleaner and pleasing in your customer’s eyes.
Ok thank you for your advice.