我的代码使用了不推荐的getFontMetrics()。还有什么可供选择的?
public void setFont ( Font font ) {
if(font == null){
Font defaultFont=(Font)javax.swing.UIManager.getDefaults().get ( "Label.font" ) ;
font=new Font(defaultFont.getName(),Font.BOLD,defaultFont.getSize()+8);;
}
FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics (font) ;
fontHeight = fontMetrics.getHeight() ;
fontDescent = fontMetrics.getDescent() ;
fontLeading = fontMetrics.getLeading() ;
if ( text != null )
fontWidth = Toolkit.getDefaultToolkit().getFontMetrics (font).stringWidth ( text ) ;
currentFont = font ;
super.setFont ( font ) ;
}有什么建议吗?
发布于 2013-03-20 23:22:48
Javadoc告诉你
从JDK1.2版本开始,由Font方法getLineMetrics代替。
https://stackoverflow.com/questions/15536588
复制相似问题