Java 中是否有任何内置方法来增加字体大小? [英] Are there any built-in methods in Java to increase Font size?

查看:41
本文介绍了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);

这篇关于Java 中是否有任何内置方法来增加字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆