I have following code that is used to compute dialog title width.
FontRenderContext frc = new FontRenderContext(null, true, true);
TextLayout tl = new TextLayout(getTitle(), getFont(), frc);
double w = tl.getPixelBounds(null, 0, 0).getWidth();
However for some reason text width is computed wrongly. I checked this code for computing radio button label text width and it worked correctly. My main concern is about dialog font, I am not sure if I correctly get it.
For example for title test
computed width is 20
however actual width is 23
. The longer string is the bigger difference between computed and actual widths.