Display the label


I have a button to download a file and display it.
when the file name is very large it does not appear in full in my label because it has a specific size.
I want the label text do “/ br” in the middle of continuous text and display, when the site is not enough.

how to do this please?


myLabel.setWidth(“200px”) or myLabel.setWidth(null);

Labels do by default have 100% width which for the label prevents wrapping to multiple rows.

By setting the width of the label to a fixed pixel size the label gets a maximum width and will also force its parents to be at least of the same width. If you set the width to undefined (null), the label will use the space that is otherwise allocated to it.

I created a fixed size label that I want to display text.
When the text exceeds the size of the label, it no longer appears.
When the width of the label is “auto”, It shifts the other elements of my form.
How to have a fixed size label that returns the text automatically wrap if it exceeds the size of the label?

In what way are the other elements shifted?

The trick is that you should set the width as fixed to make it wrap at a certain width. Then you should also leave the height undefined to let it grow when the number of rows changes. If both dimensions are fixed, text that doesn’t fit will disappear as there is no room for if.

The problem seems to still be there. Label does’n know how to handle a large strings without spacing or large numbers.
In case of a number, it should continue printing on the next line when maximum width of the label is met, but it doesn’t.
Is there any build in ways to go around this problem?

Is this perhaps the thing you’re looking for:

“Normally, line breaks in text can only occur in certain spaces, like when there is literally a space or a hyphen. When you set word-break to break-all, line breaks can occur between any character.”