I have created a swing application and I invoked it remotely via putty. In the actual system the font size is coming proper with the below code but at remote console I am not getting the size of the font.
I am using the below code to find the font size in pixels for the current environment:
FontMetrics metrics = control
.getFontMetrics(control.getFont());
int hgt = metrics.getHeight();
int adv = metrics.stringWidth();
but the above code is not working when invoked remotely from putty.
I used the approach from http://docs.oracle.com/javase/tutorial/2d/text/measuringtext.html
Do anyone know how to handle it.
Help is appreciated.
.stringWidth
is missing a String
parameter. The method takes that String
and measures it with the given Font
, resulting in the given text's advance width . You should re-read that documentation you linked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.