Java 中是否有任何内置方法来增加字体大小?
问题描述:
Java 中是否有增加字体大小的内置方法?
Are there any built-in methods in Java to increase Font size?
答
Font
类允许您指定字体大小.
The Font
class allows you to specify font size.
因此,要创建字体,您可以执行以下操作:
So, to create a font you do something like this:
Font f = new Font("serif", Font.PLAIN, fontSize);
fontSize
参数将决定您的 Font
的大小.
The fontSize
parameter will determine the size of your Font
.
您实际上无法更改现有 Font 对象的大小.实现类似效果的最佳方法是使用 deriveFont(size)
方法创建一个新的几乎相同的Font
,但大小不同.
You can't actually change the size of an existing Font object. The best way to achieve a similar effect is to use the deriveFont(size)
method to create a new almost identical Font
that is a different size.
Font biggerFont = existingFont.deriveFont(bigNumber);