I need to find the width of the text drawn on the screen. This thread assumes that FontMetrics.stringWidth () will sometimes not be as accurate as FontMetrics.getStringBounds ().
Does anyone know if this is correct, and if so, in what context is this difference visible? Most likely, FontMetrics.stringWidth () is used, including in SwingUtilities.computeStringWidth (). In addition, the obvious advantage is that it does not require a graphic object, but this in itself, combined with the fact that anti-aliasing and similar settings are defined in the Graphics object, can explain why FontMetrics.getStringBounds () can be more accurate.
source
share