; else{
temp = temp.substring(i);
if (temp.substring(0, 1).equals("\n")) {
temp = temp.substring(1);
}
}
}
}catch(Exception e)
{
System.out.println("getSubsection:"+e);
}
return vector;
}
再改一下调用的地方:
Font font = Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN, Font.SIZE_SMALL);
g.setFont(font);
Vector vector = getSubsection(strGamehelp,font,getWidth()-10," ,.?!");
这样,对于英文我们也可以正确的自动断行显示了。
终于,你可以坐下来,喝杯水(咖啡被抢光了),听点music,享受一下:
1、通用性好,自动适应不同的屏幕大小,各种语言文字通吃。
2、工作量小,你不用去辛苦手工分行,更不用为了加一个字而全部重新来过。想调整宽度?改一个参数就好。