This is probably a very easy question, but as I don't really know what I'm looking for, I couldn't succeed to find the solution...
I'm using a JLabel inside which I put a html string. My string is obtained by Jsoup Then, I want to resize the JLabel to make it fit the string. For that, I'm using the FontMetrics.stringWidth method which works fine... Except in the case I have special characters, such as "è", "ç", "ô", etc. In this case, the characters becomes sth like ô
, or é
, and the stringWidth takes it into account.
for instance, FontMetrics.stringWidth(HTMLFormating("é")) will give me the stringWidth of ("é
") which is far longer... My expected result is that when I measure the length of "é
chec" for instance, I get the same result as for "echec"
What is the solution ? Is there a way to transform back the html string into a "normal" string ? Or should I use another method ?
Thanks for your help !
Just check the preferred size of the label once the String has been added.