I want to use the method public int stringWidth(String str), from java.awt.FontMetrics, to check how wide a String gets when I draw it to the display.
So if I have the following code:
Font f = new Font("Times New Roman", 0, 20);
String str = "Hello World";
How can I get the width of which the string is drawn?
I have tried:
string_width = stringWidth(str); //error: Undefined name stringWidth
I also tried to make an instance of FontMetrics
FontMetrics fm = new FontMetrics(f);//error: Cannot 'new' an instance of abstract class 'FontMetrics'